What is the life cycle of Servlet?

Answer Posted / shaik baji

Servlet life cycle contains the following steps in it:

step 1: When the first request comes to the servlet, the
container will load the servlet if and only if the user is
not specified <load-on-startup> tag in web.xml

step 2: The container will instantiates the servlet

step 3: The container will invoke the init() method of the
servlet with the ServletConfig as a parameter

step 4: The container will create the thread for that
request and invokes the service() method

step 5: Once the service method execution is completed the
container will invoke the destroy() method to release the
Servlet object.

Step 6: The servlet will unloaded from container when the
web server or the web application is getting shutdown.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is mutual exclusion? How can you take care of mutual exclusion using java threads? : Java thread

672


What is map and hashmap in java?

612


What is final access modifier in java?

585


Write a function for palindrome and factorial and explain?

648


What is meant by method?

574






Java Compiler is stored in JDK, JRE or JVM?

1043


What is the list interface?

600


What is object data type?

558


How does arrays sort work in java?

592


what is meant by Byte code concept in Java?

592


If we don’t want some of the fields not to serialize how to do that?

559


What is the difference between ArrayList and Vector? which one is better in Java

597


what is a green thread? : Java thread

567


Can we modify the throws clause of the superclass method while overriding it in the subclass?

543


What is the difference between serializable and externalizable interface?

563