Name

<error-page>

Synopsis

The <error-page> element can define pages that inform the user about various errors.

Syntax

<error-page>
  <error-code>errorCode</error-code> |
    <exception-type>className</exception-type>
  <location>pagePath</location>
</error-page>

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 be used to specify a Java exception class name, to use a special page to handle exceptions thrown by servlets and JSP pages. The <location> subelement 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 Faces 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.