InfoCenter Home >
4: Developing applications >
4.2: Building Web applications >
4.2.1: Developing servlets >
4.2.1.3: Servlet content, examples, and samples >
4.2.1.3.5: Enhancing servlet error reporting >
4.2.1.3.5.2: Example: JSP file for handling application errors

4.2.1.3.5.2: Example: JSP file for handling application errors

As illustrated in the following code example, specify "ErrorReport" for the id value. The error page loads an instance of code from the request space named "ErrorReport" to read the properties. If the default scope (scope="page") is used, a new instance of the code is created and the properties are blank.

    <html>
    <jsp:useBean id="ErrorReport" class="com.ibm.websphere.servlet.error.ServletErrorReport"
    scope="request" />
    <head>
    <title>
    ERROR: <%= ErrorReport.getErrorCode() %>
    </title>
    </head>
    
    <body>
    <H1>
    This error occured while processing the servlet named:
    <%= ErrorReport.getTargetServletName() %>
    </H1>
    <B>My Message: </B><%= ErrorReport.getMessage() %><BR><BR>
    <B>My StackTrace: </B><%= ErrorReport.getStackTrace() %><BR>
    </body>
    </html>
    
If you do not want to write your own error, consider adding the optional internal servlet, com.ibm.servlet.engine.webapp.DefaultErrorReporter, to your Web application.

Go to previous article: Public methods of the ServletErrorReport class Go to next article: Serving servlets by classname

 

 
Go to previous article: Public methods of the ServletErrorReport class Go to next article: Serving servlets by classname