views:

18

answers:

1

Hi,

is it possible to define two sections in the web.xml in order to catch two different exception types:

<!-- general exception -->
<error-page> 
  <exception-type>**java.lang.Exception**</exception-type> 
  <location>/generalError.jsp</location> 
</error-page>

<!-- specific exception -->
<error-page> 
  <exception-type>org.myapp.myException</exception-type> 
  <location>/sessionTimeout.jsp</location> 
</error-page>

Does it has any conflict?

THANKS!

+1  A: 

No, there is no conflict and it will work as intended. This is what the servlet spec 2.5 (9.9.2) says:

The closest match in the class hierarchy wins.

So myException (and its sub-classes) will use sessionTimeout.jsp, and all others generalError.jsp.

Tim Jansen