1
votes

If the user enters a path (=name of webapp) which is not available on Tomcat then he will see the default 404 Tomcat page. As an example http://localhost:8080/asdf and there is no webapp on Tomcat called "asdf". Is there a way to handle these situations? As an example showing him a custom not-found.html instead of the default Tomcat error page?

There are many posts in web but all of them handle specific 404 errors of a certain webapp like http://localhost:8080/webapp1/this_path_now_does_not_exist.

1
@AlanStallwood: of course they will work only on my machine. The other post has not an approved answer and I have also already tried that technique. However it did not work and the reason is probably the wrong location of the .html file. I have not figured out the correct path yet. - mkn

1 Answers

2
votes

Yes it is possible.You can add following lines to CATALINA_HOME/conf/web.xml

<error-page> 
    <error-code>404</error-code>
    <location>/error/not-found.html</location>
</error-page>