Java Servlet Programing Laungage

Java Servlet Projects

Servlet Project 3

Java Servlet : Package javax.servlet, Life Cycle and Non Life Cycle Methods of Servlet Interface
Previous Home Next

javax.servlet and its subpackages:

javax.servlet and javax.http.servlet are two packages which provided interface and classes for writing servlets.These contain classes and interfaces of servlet API.At the core of servlet API is an interface named javax.servlet.Servlet.This interface provides life cycle methods of a servlet.

Life Cycle Method of servlet
  1. init(): This method is invokes only one's just after a servlet object is created.It is used by the server to provide the reference of an object of type ServletConfig to the servlet.javax.servlet.ServletConfig is an interface of servlet API implementation of which is provided by server vendor.
    	public void init(ServletConfig config);
  2. service(): This method is invoked by the server each time a request for the servlet is received.It is used by the application developer to process request and generate dynammic contents.
    public void service (ServletRequest request,
    	ServletResponse response)
    throws ServletException,IOException ;
Non Life Cycle Method of Servlet Interface
  1. getServletConfig(): It is used by the application developers to obtain the reference of ServletConfig object from the servlet.
    	public ServletConfig getServletConfig();
  2. getServletInfo(): This method is used by the application developer to describe their servlet's.
    	public String getServletInfo();
Previous Home Next