What is the best way to display errors to users when using JSPs? - Weblogic

This is a discussion on What is the best way to display errors to users when using JSPs? - Weblogic ; Hello, Could someone suggest me the best way to display errors to users when using JSPs? Many thanks in advance. Rino...

+ Reply to Thread
Results 1 to 3 of 3

Thread: What is the best way to display errors to users when using JSPs?

  1. What is the best way to display errors to users when using JSPs?


    Hello,

    Could someone suggest me the best way to display errors to users when using JSPs?

    Many thanks in advance.

    Rino

  2. Re: What is the best way to display errors to users when using JSPs?



    The 'errorPage' attribute of the 'page' directive forwards uncaught run-time exceptions
    to an error processing page. For example:

    <%@ page errorPage="error.jsp" %>

    redirects the browser to the JSP page error.jsp if an uncaught exception is encountered.


    Within error.jsp, indicate that it is an error-processing page, via the directive:



    <%@ page isErrorPage="true" %>

    The Throwable object describing the exception may be accessed within the error
    page via the 'exception' implicit object.


    <% if (exception != null) { %>

    An exception was thrown: <%= exception %>

    With the following stack trace:



    <%
    ByteArrayOutputStream ostr = new ByteArrayOutputStream();
    exception.printStackTrace(new PrintStream(ostr));
    out.print(ostr);
    %>




    "Rino Srivastava" wrote:
    >
    >Hello,
    >
    >Could someone suggest me the best way to display errors to users when
    >using JSPs?
    >
    >Many thanks in advance.
    >
    >Rino



  3. Re: What is the best way to display errors to users when using JSPs?


    Thanks for the code snippet!

    Rino

    "Deepak Vohra" wrote:
    >
    >
    >The 'errorPage' attribute of the 'page' directive forwards uncaught run-time
    >exceptions
    >to an error processing page. For example:
    >
    ><%@ page errorPage="error.jsp" %>
    >
    >redirects the browser to the JSP page error.jsp if an uncaught exception
    >is encountered.
    >
    >
    >Within error.jsp, indicate that it is an error-processing page, via the
    >directive:
    >
    >
    >
    ><%@ page isErrorPage="true" %>
    >
    >The Throwable object describing the exception may be accessed within
    >the error
    >page via the 'exception' implicit object.
    >
    >
    ><% if (exception != null) { %>
    >

    An exception was thrown: <%= exception %>
    >
    >

    With the following stack trace:
    >


    >
    ><%
    > ByteArrayOutputStream ostr = new ByteArrayOutputStream();
    > exception.printStackTrace(new PrintStream(ostr));
    > out.print(ostr);
    >%>
    >

    >
    >
    >
    >"Rino Srivastava" wrote:
    >>
    >>Hello,
    >>
    >>Could someone suggest me the best way to display errors to users when
    >>using JSPs?
    >>
    >>Many thanks in advance.
    >>
    >>Rino

    >