Answer Posted / rama
The three important functions that implement the life cycle
of servlet are init(),service(),destroy().
When a client/user specifies a request by entering the
URL in the browser the browser generates an HTTP request
for it and sends to the server.
On receiving the HTTP request the server maps a servlet
to this request. the servlet is then dynamically retrieved
and loaded in the memory.
The server now calls the init() method of the servlet.
Parameters can be sent to configure the servlet. This
method is called only once when the servlet is first
loaded.
When a request arrives for this servlet the server
invokes the service() method. this is the method which
handles all the HTTP requests and formulates HTTP response.
For every request service() method is called.
When the server decides to unload the servlet it calls
the destroy() method. Any resources which were used by the
servlet or any open files or any database connections can
be restored so that the memory used by these objects and
the servlet can then be garbage collected.
| Is This Answer Correct ? | 15 Yes | 0 No |
Post New Answer View All Answers
What's the architecture of a servlet package?
What is the difference between the include() and forward() methods?
Can we use threads in Servlets?
How the typical servlet code look like ?
Can we override destroy method in servlet?
List out difference between a JavaBean from a Servlet?
What is URL Encoding?
Explain the features are in servlet 3?
List some life cycle methods of a servlet.
How can we invoke another servlet in a different application?
What are the uses of servlets?
what do you understand by url rewriting?
How do you design microservices?
Define the servlet mapping.
What is the