Back to Top

Saturday, 4 February 2012

J2EE: SERVLET: Servlet Life Cycle

  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.

    Describes the Servlet Life Cycle within Web container or Web Server

                       *Unavailable exception thrown       *Initialization failed

    Anijit Sarkar

    22 Responses to “ J2EE: SERVLET: Servlet Life Cycle ”

    Jaydeep said...
    26 February 2012 at 13:26

    Its really helpful!!


    anij said...
    5 March 2012 at 02:00

    Thanks for visiting! :)


    namastu said...
    19 April 2012 at 01:13

    Thanks for sharing the information i found it very useful.

    Thanks again..


    anij said...
    19 April 2012 at 22:13

    @namastu

    you r most welcome my friend!!


    Asif said...
    6 September 2012 at 18:00

    its great yar !


    Asif said...
    6 September 2012 at 18:02

    have u any interest in data structures using c++


    Java Tutorials Blog said...
    22 December 2012 at 10:06

    very nice pictorial demonstration of servlet life-cycle. but remember that the destroy method won't be invoked if server crashes.


    tb said...
    11 September 2013 at 23:16

    ... when is the servlet loaded and unloaded? When the container (say Tomcat) gets started and shut down? ... or restarted?


    nasir husain said...
    11 September 2014 at 13:11

    important servlet interview questions with answer
    http://www.itsoftpoint.com/?page_id=2425


    nasir husain said...
    11 September 2014 at 13:14

    recently asked important servlet interview questions with answer
    http://www.itsoftpoint.com/?page_id=2425


    Michael Hussey said...
    19 August 2016 at 15:45



    Great Blog Thanks.

    Here You Can Find Your First Round Interview question For Job .

    Struts Interview Questions

    OOPs Interview Questions

    JSP Interview Questions


    Naviya Nair said...
    24 October 2016 at 15:13

    I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Java Training in Chennai | Core Java Training in Chennai

    Online Java Training Java 8 Online Training | Java J2EE Online Training | JavaEE Training Institute in Chennai Java Training Institutes

    Java Training Institutes in Chennai Java Training in Chennai


    Naviya Nair said...
    24 October 2016 at 15:21

    I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Java Training in Chennai | Core Java Training in Chennai

    Online Java Training Java 8 Online Training | Java J2EE Online Training | JavaEE Training Institute in Chennai Java Training Institutes

    Java Training Institutes in Chennai Java Training in Chennai


    Naviya Nair said...
    24 October 2016 at 15:29

    I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Java Training in Chennai | Core Java Training in Chennai

    Online Java Training Java 8 Online Training | Java J2EE Online Training | JavaEE Training Institute in Chennai Java Training Institutes

    Java Training Institutes in Chennai Java Training in Chennai


    Lucky Srivastava said...
    1 May 2017 at 15:12

    Hey Nice blog,Thanks for sharing this blog.!!!

    Embedded system training in lucknow

    Best python training in lucknow

    php industrial training in Lucknow

    Live projects training in Lucknow

    B-tech projects in Lucknow


    santhosh kumar said...
    3 May 2017 at 12:20

    The blog gave me idea about the servlet and The life cycle of servelet are explained in an easy and an understandable manner Thanks for sharing this post
    Java Training in Chennai


    sunitha vishnu said...
    17 May 2017 at 11:01

    This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharng this information,this is useful to me...
    Android training in chennai
    Ios training in chennai


    Karthika Shree said...
    19 May 2017 at 10:55

    It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command.
    Java Training in Chennai


    Reena raj said...
    19 May 2017 at 13:28

    Really it was an awesome article...very interesting to read..You have provided an nice article....Thanks for sharing..
    Web Design Company
    Web Development Company


    Riyas Raqim said...
    28 May 2017 at 17:08

    perfect explanation about java programming .its very useful.thanks for your valuable information. java training in chennai | java training in velachery


    preethi s said...
    20 June 2017 at 14:51

    Thanks a lot! You made a new blog entry to answer my question; I really appreciate your time and effort.And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things
    java training institutes in chennai | java j2ee training institutes in velachery


    preethi s said...
    23 June 2017 at 16:14

    Thanks a lot! You made a new blog entry to answer my question; I really appreciate your time and effort.
    Thank u so much .

    java training in chennai |
    java training institutes in chennai


    Post a Comment

    Popular Posts

    All Rights Reserved JAVA INTERVIEW QUESTIONS | Privacy Policy | Anijit Sarkar
    blog links Web Directory Academics Blogs