File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unified error handlig

 
Anthony Lopez
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic