andrew0007
andrew0007

Reputation: 1265

Web.xml ExceptionType

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 this cause any conflict?

Upvotes: 1

Views: 3047

Answers (1)

Tim Jansen
Tim Jansen

Reputation: 3358

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.

Upvotes: 5

Related Questions