I need to configure a custom 404 page in tomcat 6 and I want to avoid duplicating the files for each webapp (my plan B is to use symlinks but I'd like to avoid those as well).
This SO thread suggests creating a new 'error' webapp and putting the custom page files in there. But then I haven't figured out how I set up the custom 404 configuration in web.xml to use this url http://host:port/error/NotFound.html
If I set it up like this:
<error-page>
<error-code>404</error-code>
<location>/error/NotFound.html</location>
</error-page>
It's relative to the root of the particular webapp that the user is in at that time.
The "location" parameter is relative to a resource located in your app. Therefore it can not access an external file.
And the plan B is not the best solution because in case you redeploy your app, you should also recrate the symlink.
You may try for a plann C, using a simple jsp page (in every application) that redirects where you like. Eg:
web.xml:
<error-page>
<error-code>404</error-code>
<location>404.jsp</location>
</error-page>
404.jsp
<% response.sendRedirect("http://host:port/error/NotFound.html"); %>