Java Reference
In-Depth Information
implementation-dependent javax.servlet.jsp.PageContext abstract class for the calling
servlet and currently pending request and response. You will also notice that one of its parame-
ters is the name you specified as your error page. The following code snippet shows the call to
getPageContext() :
pageContext = _jspxFactory.getPageContext(this, request, response,
“errorpage.jsp”, true, 8192, true);
Now this instance of the PageContext object knows which page to forward all uncaught errors
to. This is done in the following code snippet:
catch (Exception ex) {
if (out.getBufferSize() != 0)
You can see that this catch block catches all uncaught exceptions and passes them to the
pageContext.handlePageException() method, which in turn places the exception into the
request and forwards it to the error page referenced during the creation of the PageContext .
In this chapter we covered the types of errors that can occur in a JSP. You have also seen how
you can handle and respond to these errors, using a JSP error page.
In the next chapter, we will cover one of the more useful JSP topics: custom JSP tags.
Search WWH ::

Custom Search