Main Content

Changing the 404 - file not found - page in Tomcat

Archive - Originally posted on "The Horse's Mouth" - 2009-03-18 01:23:06 - Graham Ellis

If you're running an Apache Tomcat web server, how do you customise your error documents? Add an <error-page> tag set into your web.xml file

To change this:



into this:




I added the following to by web.xml:

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


and put the following broken.html file into my web application:

<head>
<title>Sorry - no such page</title>
</head>
<body>
<h1>Oops - I don't have that page</h1>
This is our "error 404" page. Please
visit <a href=http://www.wellho.net>our
home page</a> to learn about our courses.
</body>


Do you want to know how to increase the amount of memory that the JVM gets given in Tomcat? That's in another post - here - which I promised today's delegates I would mention for them!