*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes error-page precedence Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "error-page precedence" Watch "error-page precedence" New topic
Author

error-page precedence

Todd Farmer
Ranch Hand

Joined: May 28, 2004
Posts: 59
I'm trying to set up several error-handling pages on Tomcat 5.0. The first error page captures java.lang.ArithmeticExceptions:



When implemented by itself, this works fine when I performa division by zero. However, when I add a more generic error-page, this generic error-page gets invoked rather than the page designed to catch ArithmeticExceptions:



I've tried changing the order of the <error-page> elements in the web.xml, but that doesn't affect behavior. The code that throws ArithmeticExceptions gets caught in the generic error-page, regardless of the listed order in the web.xml document.

Is there any way to control this? I have to assume there is. I want to have a generic error-handling template so that end users don't ever see raw error info from Tomcat, but I also want to catch specific errors (say, database connectivity errors) in specific templates.

Todd Farmer
chowdary Thammineedi
Ranch Hand

Joined: Aug 16, 2004
Posts: 126
Is it because everything propagated from a JSP page (I mean all errors) are wrapped in a Throwable?

Somebody, please clarify.

The servlet spec says the container has to choose the closest match (Interstingly, NOT the EXACT match) while going through the error-pages listed in the DD. If it could not find anythig that matches, it can "UNWRAP" the error or the exception and make another sweep through the error pages declared in the DD.

NOTE: This is not the exact quote from the spec. But equal to it.

But this is only in the Servlet 2.4 spec. I did not find it anywhere in the JSP spec.

Is every exception or error that is propagated out of a JSP Page wrapped in a Throwable? and is the matching done for the Throwable on the first pass?

Any and every explanation is welcome. How can we test this thing?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: error-page precedence
 
Similar Threads
tomcat 5 and error page
error-page in DD
Cannot print exception message
Implicit variable "exception" is null
error handling in web.xml