Advanced java programming
Life cycle of Servlet
M.Jeevana sujitha
Assistant Professor
Department of Computer Science and Engineering
SRKR Engineering College, Bhimavaram, A.P. - 534204
OBJECTIVES
The Objective of this lecture is
Life cycle of Servlet
Life cycle of Servlet
Life cycle of Servlet
init(): The init() method is designed to be called only once in the life cycle of servlet.
Syntax:
public void init() throws ServletException
{
Initialization code
}
Life cycle of Servlet
service(): The service () method is the main method to
perform the actual task.
requests coming from the client and to write the
formatted response back to the client.
server creates a new thread and calls the service()
method.
POST) and calls doGet() or doPost() methods.
Syntax:
public void service(ServletRequest req, ServletResponse res)
{
Actual business logic for providing service to client
}
Life cycle of Servlet
destroy(): The destroy() method is called only once at the end of the life cycle of servlet.
Syntax:
public void destroy()
{
Closing database connections
}
THANK YOU