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 are the phases of the servlet life cycle?

1052


What are some disadvantages of storing session state in cookies?

968


Is tomcat a servlet container?

979


Which method of the httpservletrequest object is used?

1014


Explain the servlet context.

1063


How we can get ip address of client in servlet?

935


Why do we need a constructor in a servlet if we use the init method?

986


What is the need of servlet filters?

938


What are the uses of servlets?

1072


How does Cookies work in Servlets?

1118


What is servlet? Explain

1007


List out difference between a JavaBean from a Servlet?

967


List some life cycle methods of a servlet.

1006


What are all the protocols supported by httpservlet?

1184


List out the difference between ServletConfig and ServletContext?

985