This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what happend,when we call destroy() in service() method?

 
pcreddy narra
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what happend,when we call destroy(), in service() method?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when you call the destroy method, the destroy method gets called. Is this what you expected?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you wanted to know does this cause the servlet to be unloaded or similar? No it does not. The confusion here is in cause and effect - the servlet going out of service causes the destroy() method to be called and gives you achance to clean up resources. Calling the destroy method does not cause it to be unloaded.

Dave
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dont worry , the Servlet won't die.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In simple terms:
The destroy method is not there for you to call.
It's there for the servlet container to call.

If you want something to happen when your servlet is destroyed (logging, cleaning up open file handlesn, etc...), put some code in the destroy method and the container will run it when the servlet is destroyed. Mostly, this happens when the app is stopped or reloaded.
 
dema rogatkin
Ranch Hand
Posts: 294
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have feeling that servlet specification 2.6 should include methods to unload servlet. I notice that question about destroy is so frequently asked. From other side probably destroy needs to be renamed to something more clue giving, like onPreUnload().
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have feeling that servlet specification 2.6 should include methods to unload servlet.
But why would a servlet author want to unload a servlet themselves when the entire life cycle is maintained by the container? Wouldn't this leave the container a bit puzzled about what to do with requests coming to that servlet?
From other side probably destroy needs to be renamed to something more clue giving, like onPreUnload().
Note the use of the @PreDestroy annotation now available in Java EE 5 which replaces the need for an explicit destroy() method (although that's still in the interface contract). You could therefore have a method:
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by dema rogatkin:
I have feeling that servlet specification 2.6 should include methods to unload servlet.


Why? You can easily take a servlet out of service by throwing an UnavailableException.
[ June 01, 2006: Message edited by: Bear Bibeault ]
 
dema rogatkin
Ranch Hand
Posts: 294
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, it's helpful.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic