Friday, 3 February 2012
J2EE: SERVLET: Servlet Life Cycle
Do you like this Article?
Life cycle of a servlet starts when its first load in the memory space in web server and ends when unloaded from the server memory. we can divide this in 3 steps.
- Server loads the servlet class.
- Creates an instance for the servlet class.
- Server initializes the instance by calling init() method.
- Server creates a request & a respond object based on the client's request.
- Invokes the service() method of the servlet, passing the request respond object.
- service() method process the request and use the respond object to create the client respond.
- service() method can invoke can also invoke other methods like doGet(), doPost(), doDelete(), doOptions(), doPut() and doTrace().
- Server calls the destroy() method to relinquish any resources such as file handles that are allocated to that servlet. destroy() method is invoked once in a servlet's life time.
- Then the server unload the servlet and its objects, and it's memory can be garbage collected.
Subscribe to:
Post Comments (Atom)









7 Responses to “J2EE: SERVLET: Servlet Life Cycle”
25 February 2012 23:56
Its really helpful!!
4 March 2012 12:30
Thanks for visiting! :)
18 April 2012 12:43
Thanks for sharing the information i found it very useful.
Thanks again..
19 April 2012 09:43
@namastu
you r most welcome my friend!!
6 September 2012 05:30
its great yar !
6 September 2012 05:32
have u any interest in data structures using c++
21 December 2012 20:36
very nice pictorial demonstration of servlet life-cycle. but remember that the destroy method won't be invoked if server crashes.
Post a Comment