This chapter is from the book

This chapter is from the book

The Web application framework provides a simple way to customize the look of
error messages that can occur while users are accessing your pages. As you know,
error messages are thrown because of syntax problems in your code, because of
database connection problems, or just because the user has left out one or more
required fields while filling out a form.

The application framework enables you to customize any of these error
messages. You can even hide them from the user's view entirely, if you
want. This enables you to maintain a consistent look and feel throughout an
application, even when those dreaded error messages are thrown.

Creating an Error Page

The first step in outputting errors is to create an error page. Take a look
at the error1.jsp page shown in Listing 1.

There is only one distinction between this page and a regular error page:

<%@page isErrorPage="true" %>

This line allows the page to accept and display any exception
information from the page that sent it. So, for example, if a file called
whatever.jsp has an exception, and it is told to load
error1.jsp as the error page, error1.jsp obtains all the
exception information from whatever.jsp.