Error pages for JavaServer Pages

When a client request is processed, runtime errors can occur in the body of the implementation class for a JSP or in Java code that is called by the page. You can handle these exceptions in the JSP code using the Java language’s exception mechanism.

Uncaught exceptions

Use an error page that you specify using a page directive to handle exceptions that are thrown from the body of the implementation class and are not caught. Both the client request and the uncaught exception are forwarded to the error page.

To specify an error page for a JSP, set its errorPage attribute to the URL of the error page in a page directive:

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

The java.lang.Throwable exception is stored in the javax.ServletRequest instance for the client request using the putAttribute method, using the name javax.servlet.jsp.jspException.