Skip to Main Content
Java Servlet Programming, 2nd Edition
book

Java Servlet Programming, 2nd Edition

by Jason Hunter, William Crawford
April 2001
Intermediate to advanced content levelIntermediate to advanced
780 pages
23h 48m
English
O'Reilly Media, Inc.
Content preview from Java Servlet Programming, 2nd Edition

Name

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Servlet Programming

Java Servlet Programming

Jason Hunter

Publisher Resources

ISBN: 0596000405Supplemental ContentErrata Page