2

I'm using JSF2 and Glassfish 3.0.

I have a very simple application and I'm trying to set up some default error pages for 404 and 500 error.

This is the WEB.XML section:

<error-page>
    <exception-type>404</exception-type>
    <location>/error.xhtml</location>
</error-page>

<error-page>
    <exception-type>500</exception-type>
    <location>/error.xhtml</location>
</error-page>

Even though error.xhtml exists, In the browser I still get the standard HTTP Status 404 - warning.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
TGM
  • 1,659
  • 10
  • 30
  • 45

1 Answers1

13

The <exception-type> should point to the full qualified name of a subclass of java.lang.Exception. E.g.

<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/expired.xhtml</location>
</error-page>

But what you've there are just HTTP status codes. You should be using <error-code> instead.

<error-page>
    <error-code>500</error-code>
    <location>/error.xhtml</location>
</error-page>

By the way, I wouldn't let 404 and 500 point to the same error page. A 404 is a "page not found" which is usually client's own mistake, not server's mistake. Getting a general error page instead of a "page not found" would then be very confusing.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555