Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ServletException

 
suman.pulikond a
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What actually happens if i throw a ServletException from doPost()?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The container will clean up the request.
If an error page was defined for ServletException, it will be shown.
If an error page was defined for ServletException.getRootCause, it will be shown.
Otherwise, an ugly browser defined error page will be shown.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will get error page specific to error code 500.
 
suman.pulikond a
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not that, what happens to the servlet? will the container destroys instance or thread?
 
nelson christos
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
destroy() is only called once all threads within the servlet's service method have exited or after a timeout period has passed.
 
nelson christos
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
destroy() is only called once all threads within the servlet's service method have exited or after a timeout period has passed.
 
nelson christos
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
destroy() is only called once all threads within the servlet's service method have exited or after a timeout period has passed.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calling of the destroy method is totally upon the mercy of the container.Probably when you bring down the server (or, bring down a context using container manager) then it calls destroy method of all the sevlets.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want a servlet to take itself out of action due to some problem, throw an javax.servlet.UnavailableException - the servlet container will then not even try to send it requests.

Bill
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"suman.pulikond a",

You have previously been warned on one or more occasions regarding adjusting your display name to meet JavaRanch standards. This is not optional. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it prior to your next post.

Your display name must be a first and a last name separated by a space character, and must not be obviously fictitious. Initials for a last name are not acceptable.

Be aware that accounts with invalid display names are removed.

bear
JavaRanch Sheriff
[ October 10, 2006: Message edited by: Bear Bibeault ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic