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

What is the use of send redirect () method?

1094


What is the default http method in the servlet?

1306


If a servlet is not properly initialized, what exception may be thrown?

1186


What is servlet invoker?

1043


What is the disadvantage of cookies?

997


Write a program to show the functionality of servlets.

1016


What are the different methods involved in the process of session management in servlets?

1271


What if you need to span your transaction across multiple servlet invocations?

1094


Explain servlet life cycle?

1140


What is load-on-startup in servlet?

1145


What is the inter-servlet communication?

1178


Why servlet is faster than jsp?

1072


What do you mean by cgi and what are its drawbacks?

989


What is session tracking?

1217


Can we fetch the attributes related to a servlet on a different servlet?

1148