Haina Minawa wrote:The super exception class always takes over precedence...
Seetharaman Venkatasamy wrote:most specific match win!
I've seen both these statements, but they can't both be correct! I decided since I couldn't find a good clear answer googling, I'd try for myself. I created two Exception classes - a GenericException and a SpecificException as a subclass of the former. I then added this to my web.xml:
When I build a servlet that throws a SpecificException, the SpecificExceptionHandler.jsp is served with Tomcat 6.0. Same with Tomcat 5.5. If I reverse the entries in my web.xml, same thing - the more specific class is matched.
If that's any indicator of the spec (I hope it is), it looks like it favors the most specific exception class.
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
Most likely is that your ViewExpiredException is being wrapped by another exception of some description - ServletException? Thus it doesn't match on the first pass.
Basically it makes a pass through the list of handled error pages.
If it doesn't find a match, then it looks at the exception cause, and tries that for a match.
Because you have a matcher for "Exception" it stops there without looking at the cause.
If you didn't have the declaration there with java.lang.Exception, it would probably work as you were wanting it to.