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 i call destroy() method in init() method of servlet

Answers were Sorted based on User's Feedback



can i call destroy() method in init() method of servlet..

Answer / sunil jaiswal

Yes, we can call destroy method from init method without any worry. Destroy method will be called up as calling any other method. Request shall still be process afterwards through service method(doGet, doPost etc). Because calling destroy method doesnt mean the killing the servlet instance. Calling the init, service and destroy method is in the specification of servlet lifecycle. So we can not alter those specification through outside. Once the servlet container thinks the servlet is of no use at some time(at the server shutdown) the container surely will be calling up the destroy method prior to destroy the servlet instance.

Is This Answer Correct ?    10 Yes 0 No

can i call destroy() method in init() method of servlet..

Answer / archana

yes, u can call destroy() method in init() of Servlet.

but calling destroy() in this way doesnt unload servlet
from servlet container.

Is This Answer Correct ?    8 Yes 4 No

can i call destroy() method in init() method of servlet..

Answer / deepesh

Yes, We can call destroy() from init() method but after
coming out from the destroy() it will again process the init
() method like the life cycle has to be. Thus we can not
control the servlet life cycle, though we can call destroy
() from init().

Thanks.

Is This Answer Correct ?    2 Yes 0 No

can i call destroy() method in init() method of servlet..

Answer / yathirajulu

yes, we call destroy() in init(),because both are called once.

Is This Answer Correct ?    2 Yes 1 No

can i call destroy() method in init() method of servlet..

Answer / helper

Shekhar babu, if you don't know anything. why are you
answering questions. Just read the answers as you should be
able to analyze your abilities.

Is This Answer Correct ?    3 Yes 2 No

can i call destroy() method in init() method of servlet..

Answer / tanuj

yes,

but genricServlet init() method initialization is different
from overriding it by you (we should not orride it).

destroy() method is used for closing many connections as
itit() method is used for starting some database and other
things.

Is This Answer Correct ?    1 Yes 1 No

can i call destroy() method in init() method of servlet..

Answer / tanuj

Shekar babu is an disgrace to java community should never
blog answers,destroy() is just to inform what is to be done
when the service call is terminated it is like
on_service_destroy() what is to be done.

Is This Answer Correct ?    1 Yes 1 No

can i call destroy() method in init() method of servlet..

Answer / ravikiran.chd

yes

Is This Answer Correct ?    0 Yes 0 No

can i call destroy() method in init() method of servlet..

Answer / shekhar

no,we can't call destroy() in init() method.because of
init() and dstroy() methods are take care by web container

Is This Answer Correct ?    7 Yes 15 No

Post New Answer

More Servlets Interview Questions

What is the difference in between the httpservlet and generic servlet?

0 Answers  


In which cases Destroy() is invoked?

2 Answers  


What are different types of Servlets?

12 Answers  


When is the servlet instance created in the life cycle of servlet? What is the importance of configuring a servlet?

0 Answers  


hi.... i have problem in running of servlet. i am using Tomcat server in my pc.. The problem is when i am click on strat it will display like below FAIL - Application at context path /first could not be started.. How i can slove the problem.. help plz

3 Answers  


How do you configure a centralized error handler in servlets?

0 Answers  


How can an existing session be invalidated?

0 Answers  


How we can call a jsp from the servlet?

0 Answers  


What is the procedure of invoking different servlet in a different application?

0 Answers  


How would you create deadlock on your servlet?

0 Answers  


What is servlet invoker?

0 Answers  


How does tomcat servlet container work?

0 Answers  


Categories