Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Catching exceptions in JSP when they occur in Servlets

 
Mike Landis
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks, it started to work!
br
Mike
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic