• 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 ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Unified error handlig

Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
We cannot change unless we survive, but we will not survive unless we change. Evolving tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
    Bookmark Topic Watch Topic
  • New Topic