This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Exception in Bean creation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Exception in Bean creation" Watch "Exception in Bean creation" New topic
Author

Exception in Bean creation

Trader Joey
Ranch Hand

Joined: May 11, 2000
Posts: 33
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

Joined: May 10, 2001
Posts: 3244
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).


Dave
Trader Joey
Ranch Hand

Joined: May 11, 2000
Posts: 33
Can I have a try catch block for the <jsp:usebean ..> tag ?
Nikhil
Trader Joey
Ranch Hand

Joined: May 11, 2000
Posts: 33
I tried it. It works.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Exception in Bean creation
 
Similar Threads
Why does my JSP looses JavaBean values!
THe code ,
Doubt in Errata ; Thanks Cleared .
can't use custom URLs in the welcome-file tag of web.xml?
confusion about value attribute expression in <jsp:setProperty>