Life Cycle of servlets?

Answer Posted / shakir khan

javax.servlet.Servlet interface defines 3 methods known as
life cycle.
Servlet intialisation takesplace every first time,it
receives a request and remains in memory till times out or
server shutdown

When first request came in for a servlet,servlet invoke
init() only once.

public void init(ServletConfig config)
{
}
Thereafter if any user wants requet,it will directly
executes the service().

public void service(ServletRequest req,ServletResponse res)
throws servletException,IOException
{
}
When server wants to remove the servlet from pool ,it will
executes the destroy().

public void destroy()
{
}

Is This Answer Correct ?    14 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between the include() and forward() methods?

579


Write all the phases defined in servlet life cycle?

597


What is the purpose of requestdispatcher interface?

623


What if you need to span your transaction across multiple servlet invocations?

589


How can we achieve transport layer security for our web application?

583






When to use doget() and when dopost()?

635


What is a web container and what is its responsibility?

535


Explain in brief the directory structure of a web application?

579


Why is servlet used?

693


When is the servlet instance created in the life cycle of servlet? What is the importance of configuring a servlet?

585


What is ServletContext object?

655


How the JSP file will be executed on the Server side?

650


What is meant by servlet? What are the parameters of the service method?

587


Why do we have servlet wrapper classes?

586


What is the servletconfig object?

540