what is servlet life cycle?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / nalinscjp
Through out the time of execution of a Sevlet, there are
many methods which are important to noticed.
<a
href="http://servlet-jsp.blogspot.com/2010_03_01_archive.html">Read
here</a>
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / anu
There are 3 methods in servlet life cycle:init(),service
(),destroy().
whenever servlets loads,init() method is invoked.init
()invokes only once in whole life cycle.then service()
method is invoked which handles all the Http requests and
correspondingly generate Http response.Finally service()
method is invoked for unloading the servlet.this method is
also invoked only once.
Is This Answer Correct ? | 3 Yes | 4 No |
How is the get () method different from the post() method?
What are the benefits of using servlet over cgi?
hi actully i hav form columns with origin and destination names .as like as i need to create one more column with name amount. my requirement is when i select origin and destination columns automatically i need to get amount from database.how can i. please tel me with relative code
how do you maintain sessions in servlets?
How the typical servlet code look like ?
Hi frnds iam new to Java Kindy any one can provide or me Servlets Example code and can explain to me flow of servlets and as Jsp and Struts and provide to me some sample example on these 3 topic flow,code example,and tutorials,and related websites which i can refer....thanks in advance..........
What is ServletContext() and what is its use?
9 Answers Prime Technology, TCS,
What are session variable in servlets?
Which event is fired at the time of project deployment and undeployment?
Difference between Include, Forward and sendRedirect in Servlet?
how a servlet is instantiated, whether the container calls init() or by calling any other method? please somebody reply..
What is meant by Servlet? What are the parameters of service method?