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.
    Syntax
    	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.
    Syntax
    	public ServletConfig getServletConfig();
    	
  2. getServletInfo(): This method is used by the application developer to describe their servlet's.
    Syntax
    	public String getServletInfo();
    	

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback:
Previous Home Next