This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Handling Exceptions in JSPs

 
Angela Poynton
Ranch Hand
Posts: 3143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm investigating how to impliment error handling in some JSP's we're writing and I just wanted to check something.
Would I be correct in thinking that if a JSP in included in another JSP, and the included JSP throws a runtime exception that exception will be passed up to the JSP that included it?
if this is the case and the exception is handled properly in the calling JSP would an error still be sent to the browser??
 
Angela Poynton
Ranch Hand
Posts: 3143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK now I have established that the error is passed up to the including JSP ... now I have a problem.
I have a template jsp which includes a number of other jsps to create a page.
Now what I want is for any errors thrown in the included jsps to be forwarded onto an error.jsp using the errorPage attribute of the page directive and have that error.jsp handle the error.
I thought this would be simple enough, and it does work BUT the logs are telling me the exception is still being passed up to the template! Does anyone know a way of preventing this??
 
vikinsa
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes! the exception thrown by the included jsp will be handed over to the uncluding jsp.

Originally posted by Angela Poynton:
I'm investigating how to impliment error handling in some JSP's we're writing and I just wanted to check something.
Would I be correct in thinking that if a JSP in included in another JSP, and the included JSP throws a runtime exception that exception will be passed up to the JSP that included it?
if this is the case and the exception is handled properly in the calling JSP would an error still be sent to the browser??


------------------
Vikas Aggarwal
Technology Associate
http://www.vikinsa.com
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic