1.★ Final term July 2012Lecture 283 marks
3 stages of servlet life cycle
Show answerJawab dekhein
1. Initialization: the container loads the servlet, creates one instance and calls init() once.
2. Service: for every request the container calls service(), which calls doGet(), doPost() etc.
3. Destruction: before removing the servlet the container calls destroy() once to release resources, then the object is garbage-collected.
2.★ Final term July 2012Lecture 283 marks
What are the three stages of Servlet Lifecycle?
Show answerJawab dekhein
1. Initialization: the container loads the servlet, creates one instance and calls init() once.
2. Service: for every request the container calls service(), which calls doGet(), doPost() etc.
3. Destruction: before removing the servlet the container calls destroy() once to release resources.
3.★ Final term Spring 2010Lecture 283 marks
Name three stages of servlet life cycle.
Show answerJawab dekhein
1. Initialize: init() is called once when the servlet is first loaded.
2. Service: service() (doGet()/doPost()) is called for every client request.
3. Destroy: destroy() is called once before the servlet is unloaded, to release resources.
4.★ Final term 2014Lecture 28
What is the alternative of constructor in servlet?
Show answerJawab dekhein
init() is used instead of a constructor. A servlet is created by the container, so we do not write initialization in a constructor; init() is executed once when the servlet is first loaded, not for each request, so it is the place for one-time initialization such as loading resources or reading parameters.
5.★ Final term Feb 2012Lecture 28
Write the lifecycle of servlet?
Show answerJawab dekhein
The servlet container controls the servlet life cycle:
1. Loading and instantiation of the servlet class.
2. Initialize: init() is called once, for one-time setup.
3. Service: service() is called for each request and passes it to doGet()/doPost().
4. Destroy: destroy() is called once before the servlet is removed, to release resources; then it is garbage collected.