• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

error-page element in web.xml

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a question regarding this <error-page> element.

I read that you can specify either an <error-code> or <exception-type> inside an <error-page>, but not both under the same <error-page> element. Suppose I have three <error-page> elements in my web.xml, like below:

<error-page>
<error-code>500</error-code>
<location>/jsp/error.jsp</location>
</error-page>

<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/jsp/error.jsp</location>
</error-page>

<error-page>
<exception-type>NoPermissionException</exception-type>
<location>/jsp/NoPermissionException.jsp</location>
</error-page>

How does it know to redirect to the specified JSP if NoPermissionException is a subclass of Throwable? Also if a NoPermissionException is thrown, the HTTP code is 500, so how does it know to go to NoPermissionException.jsp instead of error.jsp as specified in <error-code>? Please explain this to me. Thank you.
 
Aaron John
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like my post was posted 4 times. Please ignore the rest
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spec states something like:
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic