When the methods init() and Distroy() will be called?

Answers were Sorted based on User's Feedback



When the methods init() and Distroy() will be called?..

Answer / tulasi vani

The servlet life cycle included init() and destroy()(Small
d).

init() is called at the beginning of the servlet,it
performs certain one time activities which are required
during the lifetime of the servlet.It may be some
initialisation of variables or a database connection.

destroy() is called to destroy the servlet.Various
resources which are held by the servlet will be
released,database connections which were opened will be
closed.Later the servlet is destroyed.

Is This Answer Correct ?    4 Yes 0 No

When the methods init() and Distroy() will be called?..

Answer / abhijitbaji

both init() and destroy() are called only once.

init() at the begining when servlet object is cerated.
destroy() when the servlet object is removed from server(at
shoutdown).

service() is called each time when request comes to servlet.

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More Servlets Interview Questions

What is Difference between JavaBeans and taglib directives?

3 Answers  


Define the lifecycle for executing a jsp page.

0 Answers  


What is Request Dispatcher?

1 Answers  


Which exception is thrown if servlet is not initialized properly?

1 Answers  


What is Single Threaded Model in Servlets? Explain this with an example?

10 Answers   Wipro,






What is servlet looping or chaining?

0 Answers  


How can an existing session be invalidated?

0 Answers  


Hi Friends, Can we make any method thread safe withour synchronized keyword?

2 Answers  


What is the role of the webserver?

4 Answers  


What is the difference between the getrequestdispatcher(string path) method of javax.servlet.servletrequest interface and javax.servlet.servletcontext interface?

0 Answers  


what is the difference b/w DispatchAction and LookUpDispatchAction?

1 Answers   Deloitte, iGate, Tech Mahindra,


What is the difference between servlet and filter?

0 Answers  


Categories