Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to configure usage of ONE custom error page for ALL error codes in tomcat's web.xml? [closed]

As said in the in the title, I want to change default error pages in tomcat and did:

<error-page>
  <error-code>500</error-code>
  <location>/error_500.html</location>
</error-page>

 <error-page>
   <error-code>404</error-code>
   <location>/error_404.html</location>
</error-page>

Is it possible to use wildcard error codes like

<error-page>
  <error-code>*</error-code>
  <location>/error.html</location>
</error-page>

?

(The example above doesn't work, but is there another way?)

Thanks

like image 523
Kai Huppmann Avatar asked Nov 15 '11 11:11

Kai Huppmann


1 Answers

No, there is no way in Tomcat.

The Servlet 3.0 specification supports a global error page as follows:

<error-page>
    <location>/error.html</location>
</error-page>

So in theory it should work in at least Tomcat 7.0. But it's not properly implemented in Tomcat 7.0. I have ever reported issue 52135 about this, but they denied it. It works on other Servlet 3.0 containers though.

You can however workaround this by implementing a Tomcat-specific ErrorReportValve class which you then register as <Host errorReportValveClass>.

like image 199
BalusC Avatar answered Oct 01 '22 14:10

BalusC