aspose file tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes multiple error-pages in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of RabbitMQ in Depth this week in the Open Source forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "multiple error-pages in web.xml " Watch "multiple error-pages in web.xml " New topic
Author

multiple error-pages in web.xml

Tim Boeckstaens
Greenhorn

Joined: Aug 07, 2012
Posts: 5
Hi,

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)

Thanks in advance
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper

Joined: Apr 07, 2010
Posts: 1986
    
  39

Hi Tim,

This is what the specs say about it:
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"

Regards,
Frits
 
jQuery in Action, 2nd edition
 
subject: multiple error-pages in web.xml