Name

<error-page>

Synopsis

The <error-page> element can define pages that inform the user about various errors. A page can be specified for an HTTP error status code, such as 404 (Not Found), using the <error-code> subelement. As an alternative, the <exception-type> subelement can specify a Java exception class name, to use a special page to handle exceptions thrown by servlets and JSP pages. The <location> sub-element contains the context-relative path for the error page:

<error-page>
  <error-code>404</error-code>
  <location>/errors/404.html</location>
</error-page>
<error-page>
  <exception-type>javax.servlet.ServletException</exception-type>
  <location>/errors/exception.jsp</location>
</error-page>

Get JavaServer Pages, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.