Reputation: 5575
How to set a custom 404 page in JBoss 5?
Upvotes: 2
Views: 4351
Reputation: 7257
In general handling custom error pages is more to do with the servlet spec rather than the actual application container. Consequently, the most common place to put this is in your web.xml
, like this:
<error-page>
<error-code>404</error-code>
<location>/my-404.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/my-500.jsp</location>
</error-page>
If the above still does not work, verify that you have the correct XSD in your web.xml, it's easy to use an old one that causes JBoss to fall back to an older version of the servlet API which doesn't recognise the above tags. In general, this one works for me with servlet 2.5:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
Out of interest, the JBoss 5.0.x and 5.1.0, the global web.xml
file is located at server/<your server>/deployers/jbossweb.deployer/web.xml
, and ROOT.war is at server/<your server>/deploy/ROOT.war
. This will allow you to make custom error pages for all applications within the server.
Upvotes: 5