Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

multiple error-pages in web.xml

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Creator of Enthuware JWS+ V6
Posts: 3343
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ever since I found this suit I've felt strange new needs. And a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic