The life cycle of a servlet?
The life cycle of a
servlet
The life cycle of a
servlet is controlled by the servlet container. We can't controlled
servlet life cycle
When very first request comes then
servlet container load and initialized serlvlet class and create object of Servletconfig and pass in into init method and
servlet container called init() methods.After that servlet container create Object of ServletRequest and ServletResponse and pass in into service() methods. init() methods called only once in life .
If other request comes then container creates Object of ServletRequest and ServletResponse and pass in into service() methods for this.
destroy() method called only when server restart(or servlet container) or shut down or no longer required for
servicing any request, the servlet container will calls the destroy()
method .
Read More →