SPIRO THE TECH GURU

Back

What are the life-cycle methods for a servlet?

By Admin on

Method Description

  • public void init(ServletConfig config)

It is invoked only once when first request comes for the servlet. It is used to initialize the servlet.

  • public void service(ServletRequest request,ServletResponse)throws ServletException,IOException

It is invoked at each request.The service() method is used to service the request.

  • public void destroy()

It is invoked only once when servlet is unloaded.

SPIRO Google Plus