Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New Servlet 3.0 global error page feature does not work on Tomcat 7

The Servlet 3.0 specification states that a global error message can be listed in the web.xml to encompass all server errors.

Example:

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

Old Method:

<error-page>
    <error-code>401</error-code>
    <location>/error.jsp</location>
</error-page>

When adding this new method to my web.xml in Tomcat 7, it does not work. How is this caused and how can I solve it?

like image 584
jnrcorp Avatar asked Nov 03 '11 15:11

jnrcorp


1 Answers

That'll be a bug in Tomcat 7. It works fine on Glassfish 3, for example.

It's time to report a bug to Tomcat guys, so I did: issue 52135.


Update: it has been closed because the Servlet spec was "not clear" that <exception-type> and <error-code> became optional. This was only shown in figure 14-10 of the Servlet 3.0 spec and nowhere literally in the text, even though the new Servlet 3.0 XSD confirms this change. This was later been reopened and a link to a nice blog article was posted which confirms this only once more. Now we have only to wait for the Tomcat developers to really fix it. Based on the Tomcat source code as far as I can see, it's not going to be a trivial fix and that was perhaps why it was closed so soon.


Update 2: this has finally been fixed and implemented in Tomcat 7.0.29.

like image 69
BalusC Avatar answered Sep 21 '22 14:09

BalusC