This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Servlets and the fly likes Unified error handlig Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Unified error handlig" Watch "Unified error handlig" New topic

Unified error handlig

Anthony Lopez

Joined: May 20, 2002
Posts: 7
I am redirecting error handlig to a servle via a jsp:forward action simply using the declarative context in the application's web.xml:
Now, the thing is that, as specified in the servlets 2.3 DTD, the servlet you are redirecting to has to be part of the same Web app context:
. . .
<!ELEMENT error-page ((error-code | exception-type), location)>
The error-page element contains a mapping between an error code or exception type to the path of a resource in the web application
<!ELEMENT error-code (#PCDATA)>
The error-code contains an HTTP error code, ex: 404
<!ELEMENT exception-type (#PCDATA)>
The exception type contains a fully qualified class name of a Java exception type.
<!ELEMENT location (#PCDATA)>
The location element contains the location of the resource in the web application
. . .
So I think you must have a redirecting JSP to a servlet, both in the same web application, possibly using general helper classes in <>/ROOT/classes
also there is no hierarchical handling here. If the Web app context does not handle the error it is not redirected to the ROOT's web.xml.
I am trying to avoid having a forwarding JSP and a servlet for each web context.
Have you found a hack aroung this?
I agree. Here's the link:
subject: Unified error handlig
It's not a secret anymore!