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

Exception in Bean creation

 
Trader Joey
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using a bean within a JSP page. In the constructor of this bean is a call to a method that could throw an Exception. How does the JSP page know that an exception was thrown during the creation of an instance of the bean class?
Thanks
Nikhil
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nikhil
The JSP knows an exception was thrown in the same way that any other part of your program knows. The exception will be thrown through the different layers of the code until it is either caught or it gets to the top most caller. IF it uncaught the entire way then your JSP will most likely send an HTML error page. Better yet, you could set the error page and then use the error information to customize the response to the user (or to yourself for debuging).
 
Trader Joey
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I have a try catch block for the <jsp:usebean ..> tag ?
Nikhil
 
Trader Joey
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried it. It works.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic