Question - What are the life cycle methods of a servlet?
Answer -
The Servlet Life Cycle consists of three methods:
- public void init(ServletConfig config): This method is used by the container to initialize the servlet, this method is invoked only once in the lifecycle of the servlet.
- public void service(ServletRequest request, ServletResponse response): This method is called once for every request, a container can’t invoke service() method until unless init() method is executed.
- public void destroy(): This method is invoked once when a servlet is unloaded from memory.