Configuring error pages in the DD
You can declare error pages in the DD based on either the <exception-type> or the HTTP status <error-code> number. That way you can show the client different error pages specific to the type of the problem that generated the error.
Declaring a catch-all error page
This applies to everything in your web app—not just JSPs. You can override it in individual JSPs by adding a page directive with an errorPage attribute.
<error-page> <exception-type>java.lang.Throwable</exception-type> <location>/errorPage.jsp</location> </error-page>
Declaring an error page for a more explicit exception
This configures an error page that’s called only when there’s an ArithmeticException. If you have both this declaration and the catch-all above, any exception other than ArithmeticException will still end up at the “errorPage.jsp”.
<error-page> <exception-type>java.lang.ArithmeticException</exception-type> <location>/arithmeticError.jsp</location> </error-page>
Declaring an error page based on an HTTP status code
This configures an error page that’s called only when the status code for the response is “404” (file not found).

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access