• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Catching exceptions in JSP when they occur in Servlets

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I have a MVC model 2 based Web application.
My simple problem is that if servlet or action class
is throwing an Exception, my jsp file does not show
errorpage that is defined into Web.xml.
What could be wrong or what could be a better way to
bring up exception occured in servlet/action to jsp
errorpage.
Br
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are throwing the exception from your servlet, of course it is not going to pick up the error page directive from a JSP that you haven't forwarded to yet.
One way to deal with this could be: in the event of an exception, forward to the error page yourself by catching the exception.
If you want your exception to be available on the error page via the 'exception' variable, add the exception as a request attribute with a key of 'javax.servlet.jsp.jspException'.
hth,
bear
 
Mike Landis
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, it started to work!
br
Mike
 
reply
    Bookmark Topic Watch Topic
  • New Topic