This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am trying to have the following error pages in my web.xml :
I make a "mistake" in the jsp page and a ClassCastException is thrown. The 2 error pages have "isErrorPage" True. The problem is that I don't see the error.jsp file but the mainError.jsp file. If I print the exception in the jsp file he says it's of type java.lang.ClassCastException. Changing the order of the error-pages doesn't seem to help. If I delete the Throwable I get the correct page.
Can anybody tell me what the spec says about this? Should the Throwable be displayed or the more specific exception? Also does the order of the error-pages matter?
I have looked on the web and here for a while but I can't find it at all. (I am studying for the 1Z0-858 exam)
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 exception-type element. A match results in the container returning the resource indicated in the location entry. The closest match in the class hierarchy wins.
So according to the specs you should be redirected to the "/error.jsp"