This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

handle exception in servlet

 
Peter Straw
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please can you tell me how it is possible to send an error message to a jsp page from a servlet when an exception has been caught.
Say I have a class MyException.java which creates a string to show a user-friendly error message. How can I get this to forward to myError.jsp as the exception class has no handle on the request or response objects for the
getServletContext().getRequestDispatcher( itsPage ).include ( itsRequest, itsResponse ) method?
many thanks
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sure -- what if you declare the exception in your web.xml like this:

FYI you can do this same kinda thing for 404, 403 and other error codes by changing the <exception-type> element to <error-code>
[ May 28, 2003: Message edited by: Jessica Sant ]
 
John Dunn
slicker
Ranch Hand
Posts: 1108
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not quite what you asked for, but may be of use anyway...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic