Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet basics

 
Amruth Puppala
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please clarify my strange doubts.

If explicitly we call following methods What is happns to the servlet lifecycile..
1. If we call destory() method in init() what happens
2.If we call init() method in destroy() what happens
3.If we call init() method in service() what happens
3.If we call destory() method in destroy() what happens

Thanks in advance for the response.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
None of these scenarios makes sense. In any case, what happens is determined by the standard rules of Java method calls. It has no bearing on the servlet lifecycle (apart from the case of a method calling itself - if that is done unconditionally, quite nasty and undesirable things may happen).
 
Amruth Puppala
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response but an we call in that way , what happens to the container flow of calling methods, if we already called destroy()..
Please need few more inputs get clarity on this
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why dont you try it yourself ?
And as said by Ulf it does not make any sense.
Also a servlet becomes a servlet only after the init() method completes.
If you wish to get in between and destroy things then be ready for the outcome.

Also I think whatever happens will be container vendor specific.


Hope this helps
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You seem to be under the impression that something happens to the servlet or the servlet container because the init or destroy methods are called - that's not the case. It's the other way around - the container calls those methods because it wants to put the servlet into service, or remove it. If other code calls them, then the code in them is executed, and that's it.
 
Amruth Puppala
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks lot
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic