JSP.2.2 Error Handling


There are two logical phases in the life cycle/processing of a JavaServer Page source file:

  • Translation (or compilation) from JSP page source into a JSP page implementation class file.

  • Per client request processing by an instance of the JSP page implementation class.

Errors may occur at any point during processing of either phase. This section describes how such errors are treated by a compliant implementation.

JSP.2.2.1 Translation Time Processing Errors

The translation of a JSP page source into a corresponding JSP page implementation class using the Java technology by a JSP container can occur at any time between initial deployment of the JSP page into the runtime environment of a JSP container and the receipt and processing of a client request for the target JSP page. If translation occurs prior to the JSP container receiving a client request for the target (untranslated) JSP page, then error processing and notification are implementation dependent. Fatal translation failures shall result in subsequent client requests for the translation target also to be failed with the appropriate error; for HTTP protocols, error status code 500 (server error).

JSP.2.2.2 Client Request Time Processing Errors

During the processing of client requests, arbitrary runtime errors can occur either in the body of the JSP page implementation class or in some other code (Java or other implementation programming language) called from the body of the JSP page implementation class. Such errors are realized in the page implementation using the Java programming language exception mechanism to signal their occurrence to caller(s) of the offending behavior. [1]

[1] Note that this is independent of scripting language; this requires that unhandled errors occurring in a scripting language environment used in a JSP container implementation be signaled to the JSP page implementation class via the Java programming language exception mechanism.

These exceptions may be caught and handled (as appropriate) in the body of the JSP page implementation class.

However, any uncaught exceptions thrown from the body of the JSP page implementation class result in the forwarding of the client request and uncaught exception to the errorPage URL specified by the offending JSP page (or the implementation default behavior, if none is specified).

The offending java.lang.Throwable describing the error that occurred is stored in the javax.ServletRequest instance for the client request using the putAttribute() method, using the name " javax.servlet.jsp.jspException ." Names starting with the prefixes " java " and " javax " are reserved by the different specifications of the Java platform; the " javax.servlet " prefix is used by the servlet and JSP specifications.

If the errorPage attribute of a page directive names a URL that refers to another JSP, and that JSP indicates that it is an error page (by setting the page directive's isErrorPage attribute to true ), then the " exception " implicit scripting language variable of that page is initialized to the offending Throwable reference.



Java 2 Platform, Enterprise Edition. Platform and Component Specifications
Java 2 Platform, Enterprise Edition: Platform and Component Specifications
ISBN: 0201704560
EAN: 2147483647
Year: 2000
Pages: 399

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net