Servlet

Java Servlet Programming, 2nd Edition > A. Servlet API Quick Reference > Servlet

 
< BACKCONTINUE >
Servlet

Synopsis

Interface Name: javax.servlet.Servlet

Superinterface: None

Immediate Subinterfaces: None

Implemented By: javax.servlet.GenericServlet

Availability: Servlet API 1.0 and later

Description

All servlets implement the Servlet interface, either directly or by subclassing the GenericServlet or HttpServlet class. Most servlet developers find it easier to subclass one of the two existing servlet classes than to implement this interface directly. The interface declares the basic servlet functionality initializing a servlet, handling a client request, and destroying a servlet.

Interface Declaration

public interface Servlet {   // Methods   public abstract void destroy();   public abstract ServletConfig getServletConfig();   public abstract String getServletInfo();   public abstract void init(ServletConfig config) throws ServletException;   public abstract void service(ServletRequest req, ServletResponse res)     throws ServletException, IOException; }

Methods

destroy()

public abstract void destroy()
Description

Called by the servlet container to indicate to a servlet that the servlet has been taken out of service. See the full description under GenericServlet.

getServletConfig()

public abstract ServletConfig getServletConfig()
Description

Returns the ServletConfig object saved by the init( ) method.

getServletInfo()

public abstract String getServletInfo()
Description

Returns a programmer-defined String that describes the servlet.

init()

public abstract void init(ServletConfig config) throws ServletException
Description

Called by the servlet container after the servlet is first loaded and before the servlet's service( ) method is called. See the full description under GenericServlet.

service()

public abstract void service(ServletRequest req, ServletResponse res)   throws ServletException, IOException
Description

Called to handle a single client request. A servlet receives request information via the ServletRequest object and sends data back to the client via the ServletResponse object.


Last updated on 3/20/2003
Java Servlet Programming, 2nd Edition, © 2001 O'Reilly

< BACKCONTINUE >


Java servlet programming
Java Servlet Programming (Java Series)
ISBN: 0596000405
EAN: 2147483647
Year: 2000
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net