Saturday, December 4, 2010

Custom 404 Page Using JBOSS (for audit purposes)




Having a custom “page not found”, or 404 page, is an important modification for any website. It’s used to enhance the user experience by presenting an easy to understand message. Sometimes it is also useful to hide information contained in those pages as it reveals information about the server it self, release etc, etc


Setting up a user friendly error page is simple enough using Apache web server. Just modify the line in httpd.conf and point it to a static HTML document:

ErrorDocument 404 /the404_page.html

With JBOSS (or Tomcat-like Java container) application server, it’s slightly trickier. It has to be handled per web application basis. The change is done on the web.xml file, with these entries:

<error-page>

<error-code>404</ error-code>
<location>/404.html < / location >
< /error-page >

For the root directory, modify the web.xml in the ./deploy/jboss-web.deployer/ROOT.war/WEB-INF directory.

No comments: