This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Problems with Exception Handling via web.xml config  RSS feed

 
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I'm tying to configure a Web App to use specific Error pages for particular exceptions, but I am running into problems.
On Sun ONE Web Server v6.1 (Servlet 2.3 / JSP 1.2) I have the following web.xml:

com.foo.MySpecialException Extends java.sql.SQLException
A bean used by various JSP pages in the app can throw com.foo.MySpecialException
From my understanding, the container should use the most appropriate <error-page> entry to handle an exception. So when my Bean throws the com.foo.MySpecialException, the container should forward it to MySpecialException.jsp. Well it doesn't; it goes to the GeneralExceptions.jsp page (the planned catch all page). A on that page displays com.foo.MySpecialException: Message Details - so I know the container is �seeing� the proper exception type.
Now if I comment out the Throwable entry in the web.xml:

I get the MySpecialException.jsp - but this eliminates the ability to handle the unforeseen exceptions that the GeneralExceptions.jsp page was meant to handle.
What am I missing here? Why is the container not using the specified page?
A big thank you in advance for any and all Assistance
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is that the JSP code is probably wrapping the actual thrown exception into a ServletException of some sort before it reaches your error pages. Try printing exception.getClass() in the catch-all JSP and seeing which class the exception really is.
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frank,
Thanks for the suggestion.
A <%= exception.getClass() %> is displaying class com.foo.MySpecialException
However, the container's error log does show:
[17/Dec/2003:13:59:11] failure ( 360): for host 127.0.0.1 trying to GET /dbgui/process.jsp, service-j2ee reports: StandardWrapperValve[jsp]: WEB2792: Servlet.service() for servlet jsp threw exception
javax.servlet.ServletException: My Bean's Specialized Message
<staack-trace>
...
----- Root Cause -----
com.foo.MySpecialException: My Bean's Specialized Message
<stack-trace>

Sorry that I missed that before. Any suggestions on how to work around this? I suppose I could catch the ServletException and then search the message string for key words to determine if I need to forward to the Special Error Page (or what error page to go to), but it seems like there should be an easier way (especially since I have different messages and they may change in the future - especially when the page is localized). Any suggestions.
Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!