I'm running an Apache Tomcat server with 2 custom servlets. The tree structure looks like:
$CATALINA_HOME/webapps/ ROOT/ WEB-INF/ servlet1/ META-INF/ WEB-INF/ servlet2/ META-INF/ WEB-INF/
I am trying to add a custom error html page for each servlet that will be displayed on error 400, 404 and when there is an exception on the servlet (such as the information that was supposed to be sent to the servlet on the http request is not there)
I added to
<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>
and I created
$CATALINA_HOME/webapps/ROOT/. This doesn't seem to be working. When I type"
www.server.com/servlet1/SomRandomStuff to get a 404, a blank page is displayed, not error.html. Something else happens when I call the servlet without passing the correct info to it, the browser will ask me if i want to download a file.
I've tried placing
error.html not on
ROOT but on the servlet1 directory. Didn't work. I checked that
error.html has the correct permissions, it is OK. I am out of ideas and the few tutorials I found online are very vague.
What am I doing wrong? How do I achieve this - display a custom error page per servlet?
Thank you for the help.