Example & Tutorial understanding programming in easy ways.

Explain the life cycle methods of a Servlet.

Explain the life cycle methods of a Servlet.

The servlet life cycle is manged by servlet container. The javax.servlet.Servlet interface defines three methods which is known as life-cycle method.

public void init(ServletConfig config) throws ServletException
public void service( ServletRequest req, ServletResponse res) throws ServletException, IOException
public void destroy()

init() :-methods used to initialized resources used in servlet .
service():- method called always when other request come.
destroy():- method called only once and used to destroy resources  which goes for garbage collected and finalized.

Read More →