Skip to Main Content
Java Servlet Programming
book

Java Servlet Programming

by Jason Hunter
November 1998
Intermediate to advanced content levelIntermediate to advanced
526 pages
14h 38m
English
O'Reilly Media, Inc.
Content preview from Java Servlet Programming

Name

Servlet

Synopsis

Interface Name: javax.servlet.Servlet

Super-interface: 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 when the server is preparing to unload a servlet. Used to clean up any outstanding resources (database connections, threads, file handles and so forth). The servlet programmer is responsible for making sure that any requests currently executing are allowed to finish.

getServletConfig()

public abstract ServletConfig getServletConfig()
Description

Returns the ServletConfig object passed to the init() method.

getServletInfo()

public abstract String getServletInfo()
Description

Returns a programmer-defined ...

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, 2nd Edition

Java Servlet Programming, 2nd Edition

Jason Hunter, William Crawford

Publisher Resources

ISBN: 156592391XSupplemental ContentCatalog PageErrata