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.
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:
<web-app>
<error-page>
<error-code>404</error-code>
<location>/the404_page.html</location>
</error-page></web-app>
For the root directory, modify the web.xml in the ./deploy/jboss-web.deployer/ROOT.war/WEB-INF directory.
Testing this setup in Firefox and Opera, the custom 404 page will automatically show up properly.
However, with Internet Explorer, a “The Webpage Cannot Be Found” message comes up instead. This is a feature of IE to show Microsoft’s version of a “friendlier error message”. In this case, we want to disable it, so the custom 404 page will show up. It can be done via Internet Options -> Advanced tab :
Update: Microsoft Help & Support site states if the 404 error page is greater than 512 bytes, then IE will not show the friendly message. So the page size must be a bigger one, not just a simple one liner.
Now that the applications are setup to serve up custom error page, here are some examples of beautiful 404 page designs to improve the user experience.