Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

the order of error-page

 
riohk kurn
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We all know that the order of exception in try-catch is not arbitary. How about the error-type inside <error-page>?
 
Sam Tilley
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No it shouldnt be because you all you are doing is linking an error that the browser generates to a specific page, and also its xml which mostly only worries about the location of elements and things
Cheers
 
R K Singh
Ranch Hand
Posts: 5384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But in web.xml order of element is important. I think this should hold true also for <error-page>
just try to throw some exception, for which there are two entries in web.xml.
 
riohk kurn
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I think there should have some rules. For example,
<exception-type>ExceptionHandler</exception-type>
...
<exception-type>SubExceptionHandler</exception-type>
So, if an object of SubExceptionHandler is invoked, will the order of the above list affect the result?
 
Maha Annadurai
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your case, the order is irrelavant. The 'SubClass' error Handler will be invoked irrespective of it's placement order.
From Servlet Spec: SRV.9.9.2 Error Pages
The web application may have declared error pages using the exception-type
element. In this case the container matches the exception type by comparing the
exception thrown with the list of error-page definitions that use the exceptiontype
element. A match results in the container returning the resource indicated in
the location entry. The closest match in the class heirarchy wins.

If you have 2 different error handlers for the SAME exception, the latter one wins.
-Maha
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic