Reputation: 1679
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.
Upvotes: 2
Views: 7928
Reputation: 1109874
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.
Upvotes: 13