Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

handle exception in servlet

 
Peter Straw
Ranch Hand
Posts: 79
  • 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
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not quite what you asked for, but may be of use anyway...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic