Explain the life cycle of servlet?

Answers were Sorted based on User's Feedback



Explain the life cycle of servlet?..

Answer / surajkumar.java

1. The servlet is controlled by the container in which the
servlet has been deployed. When a request is made to a
servlet, its mapping is searched in web.xml. If mapping
found then the web container loads the servlet class and
creates an instance of it and initializes (e.g servlet
context parameters, database connections objects etc) the
servlet instance by calling the init method.
2. Then invokes the service method, passing a request and
response object. The service provided by a servlet is
implemented in the service method of a GenericServlet and
the doMethod methods (where Method can take the value like
Get, Delete, Options, Post, Put, Trace) of an
HttpServlet. Basically a service method extract information
from the request, access external resources, and then
populate the response based on that information.
3. The container calls destroy method to remove servlet
instance. We also do some specialized handling like closing
a connection, freeing the memory used by local variables etc
by explicitly defining the destroy method inside a servlet
class.

Is This Answer Correct ?    14 Yes 0 No

Explain the life cycle of servlet?..

Answer / rjava

init
service
destroy

Is This Answer Correct ?    2 Yes 1 No

Explain the life cycle of servlet?..

Answer / sasi kumar

Initialization:A servlet is first loaded and initialized
usually when it is request by the corresponding client.
Service:After initilization,the servlet serve client on
request,implementing the application logic clients of the
web application they belong to.
Destruction:When all pending request are processed and the
servlets have been idle for a specific amount of time,they
may be destroy by the servlet and release all the resources
they occupy.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Advanced Java Interview Questions

Can I use multiple html form elements with the same name?

0 Answers  


what is Static binding?

2 Answers   Wipro,


For which statements does it make sense to use a label?

0 Answers  


What is an abstract method?

0 Answers  


What is a session? Can you share a session object between different theads?

0 Answers  






What is diffennce between AWT & SWING?

4 Answers  


What is JasperReports?

2 Answers  


which deployment descriptor element is used to configure the authentication method? a. auth-config b. login-config c. sec-config

1 Answers  


a US company has filed my H1B visa ,, and i got selected in random number process.I wanna ask Could they ask regarding my languages(java,c++) or there will b just general questions?? And wat kind of questions will they ask in embassy interview??

2 Answers  


Explain Life cycle of Servlet Filter.

2 Answers   InfoBrain, ITC Infotech,


Have you used threads in Servelet?

0 Answers   Satyam,


what's the main difference between unix os and linux os?

2 Answers   TCS,


Categories