Apache & Tomcat 404, 503 custom error page

August 17, 2010

Configure Tomcat and Apache to show custom 404 and 503 error pages. This should cover the cases when the either the page and/or application is not available.

  1. Configure Apache httpd.conf configuration file in order to show a custom 404 and/or 503 error page:

# to handle 404 page not found
ErrorDocument 404 /404.htm

# to handle 503 application not available
ErrorDocument 503 /503.htm

Note(s):

  • The file 404 error page name can be anything you want and its path is relative to the applications DocumentRoot
  • Handling the 404 error by apache can be redundant, if the application is running then the 404 is catch and handled first by tomcat
  1. Configure Tomcat web.xml file configuration file ion order to show a custom a404 error page:
<error-page>  
    <error-code>404</error-code>
    <location>404.htm</location>
</error-page>