Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Can we call destroy() method inside the init() method? What
happens when we do so?

Answer Posted / amitasite

One can call destroy method from init method. One scenario
in which you would like to call is some resource is looked
up once in init() method and cleaned in destroy() method. If
exception is thrown before it finishes as servlet is not
brought in service, container won't call destroy method. so
to keep resource clean you can call destroy() method from init()

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How we can get ip address of client in servlet?

1028


What is the directory structure of web application?

1039


How can a servlet be used to generate plain text instead of html?

995


How servlets are deployed in java?

1071


What's the difference between authentication and authorization?

1203


What are session variable in servlets?

1066


Which are the different ways you can communicate between servlets?

1051


How do servlets work?

1101


When to use doget() and when dopost()?

1154


What is servlet lazy loading?

1228


What are the different methods of session management in servlets?

1075


What is the functionality of actionservlet and requestprocessor?

1140


What is the default http method in the servlet?

1348


What are the uses of servlet

1241


What is a deployment descriptor?

1156