wood burning stoves 2.0*
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "Unified error handlig" Watch "Unified error handlig" New topic
Author

Unified error handlig

Anthony Lopez
Greenhorn

Joined: May 20, 2002
Posts: 7
Hi,
I am redirecting error handlig to a servle via a jsp:forward action simply using the declarative context in the application's web.xml:
<error-page>
<error-code>400</error-code>
<location>/ServerErr.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/ServerErr.jsp</location>
</error-page>
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?
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unified error handlig
 
Similar Threads
HttpServletResponse.sendError
error-page
Catching NullPointerException
Where does request goes?
Custom Error Messages...