Servlet Interface

public interface Servlet
This interface specifies the contact between the web container and a servlet.
When we write a servlet, we must implement this interface directly or indirectly.
Method of Servlet Interface
There are 5 method of Servlet interface.
  1. public void init(ServletConfig config) throws ServletException:
    Once the servlet has been instantiated, the web container calls the init() method. The purpose of this method is to allow a servlet to perform any initialization required before being invoked against HTTP request.
  2. public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException
    This is entry point for executing application logic in a servlet. The container calls this method in response to incoming requests.
  3. public void destroy() :
    The container calls this method before removing a servlet instance out of service.
  4. public ServletConfig getServletConfig() :
    This method return the ServletConfig when passed to the servlet during the init() method.
  5. public String getServletnfo():
      This method return the String object related information about servlet.


Latest Tutorial

Most Visited Tutorial