This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Servlets and the fly likes can we call service() and destroy() inside init() of servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "can we call service() and destroy() inside init() of servlet" Watch "can we call service() and destroy() inside init() of servlet" New topic
Author

can we call service() and destroy() inside init() of servlet

ramu yadiki
Greenhorn

Joined: Jul 26, 2013
Posts: 13

Hi friends can you explain this thing...

can we call service() and destroy() inside init() of servlet
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63349
    
  70

No, you cannot call service. Where would the request and response instances come from?

And yes, you can call destroy() but why would anyone do such a silly thing?

(And, in case you are thinking that destroy() destroys the servlet -- it doesn't.)


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: can we call service() and destroy() inside init() of servlet
 
It's not a secret anymore!