We have tomcat 9 web server in production. The problem we are facing is we want to show the custom error page for our application if tomcat receives any malformed URL as follows
or
I have added error page tag in web.xml of tomcat application server as follows
<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>
and we have error.html in our application ROOT folder in webapps directory of tomcat.
Whenever the user tries to request any nonexistent webpage he receives error page correctly corresponding to 404 error code as specified above.
Real Problem is tomcat not able to redirect to error.html when the user enters malformed URL in the browser like http://URL/|
Tomcat is showing the default 400 bad request error page instead of the custom error page.