title: Tomcat is not redirecting to 400 bad request custom error page
body: <p>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</p>
  
  <p><a href="http://URL/|" rel="noreferrer">http://URL/|</a></p>
  
  <p>or</p>
  
  <p><a href="http://URL/[" rel="noreferrer">http://URL/[</a></p>
  
  <p>I  have added  error page tag in web.xml of tomcat application server as follows</p>
  
  <pre><code>&lt;error-page&gt;
     &lt;error-code&gt;400&lt;/error-code&gt;
     &lt;location&gt;/error.html&lt;/location&gt;
   &lt;/error-page&gt;
   &lt;error-page&gt;
     &lt;error-code&gt;404&lt;/error-code&gt;
     &lt;location&gt;/error.html&lt;/location&gt;
   &lt;/error-page&gt;
  </code></pre>
  
  <p>and we have error.html in our application ROOT folder in webapps directory of tomcat.</p>
  
  <p>Whenever the user tries to request any nonexistent webpage he receives error page correctly corresponding to 404 error code as specified above.</p>
  
  <p>Real Problem is tomcat not able to redirect to error.html when the user enters malformed URL in the browser like <a href="http://URL/|" rel="noreferrer">http://URL/|</a></p>
  
  <p>Tomcat is showing the default 400 bad request error page instead of the custom error page. </p>