How to handle 404 in application context level
jakarta-ee, tomcat
Solution
You can adapt Tomcat's `conf/web.xml` file to show some other page than the default for the 404 error - see here for an example.
Extract:
<error-page>
<error-code>404</error-code>
<location>/NotFound.jsp</location>
</error-page>
Problem
I have 2 applications/projects deployed in tomcat 7 web server. There context paths are different like "project1", "project2". When I hit URLs with these context path, corresponding application loads and works fine. Valid URLs are: http://localhost:8080/project1 http://localhost:8080/project2 Now when I hit any wrong URL with correct host name and incorrect context path like /project3, it give me error message 404 not found and shows a weird screen to the user. I want to show a proper page with proper message to the end user. How can I do that in web server level?