Custom error pages on Apache Tomcat

Solution 1:

You have your page paths starting with slashes:

 <error-page>
   <error-code>400</error-code>
   <location>**/error.html**</location>
 </error-page>
 <error-page>
   <error-code>404</error-code>
   <location>**/error.html**</location>
 </error-page>
 <error-page>
   <exception-type>java.lang.Throwable</exception-type>
   <location>**/error.html**</location>
 </error-page>

In this case it might be looking for them in the root of the drive.

If they are in the same folder as web.xml you can try it this way ./error.html

Other than that, I would recommend trying the full path to the file: /var/www/error/error.html or whatever your situation is.

Solution 2:

to capture 404 for www.server.com/servlet1/SomRandomStuff move your error.html file to $CATALINA_HOME/webapps/servlet1/error.html. copy the error file to each of your webapp. Even though not the best way to handle this, it worked for me.