Saturday, 25 May 2013

Servlet Life cycle


The Servlet  has it's own life cycle .

Servlet life cycle is managed by servlet container.


lLife cycle has 3 methods and 4 phases




Life cycle methods
1)init(servlet config config)
2)service()
3)destroy()


Life cycle phases
1)instantiation
2)initialization
3)service
4) destroy


example

import javax.servlet.*;

public class LifeDemo extends HttpServlet
{

public void init(Servlet config config)
{

//init method
}


public void service(httpservletrequest req,httpservletresponse res)throws servlet Exception
{


//servicing method
}


public void destroy
{

//destroy request& response object.
}

}Aryantech india

No comments:

Post a Comment