O'Reilly logo

Java Servlet Programming, 2nd Edition by William Crawford, Jason Hunter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

GenericServlet

Synopsis

Class Name: javax.servlet.GenericServlet

Superclass: java.lang.Object

Immediate Subclasses: javax.servlet.http.HttpServlet

Interfaces Implemented: javax.servlet.Servlet, javax.servlet.ServletConfig, java.io.Serializable

Availability: Servlet API 1.0 and later

Description

GenericServlet provides a basic implementation of the Servlet interface for protocol-independent servlets. As a convenience, it also implements the ServletConfig interface. Most servlet developers subclass this class or HttpServlet, rather than implement the Servlet interface directly.

GenericServlet includes basic versions of the init( ) and destroy( ) methods, which perform basic setup and cleanup tasks, such as managing the server’s ServletConfig object. It’s good form for a servlet that overrides one of these methods to call the superclass version of the method. GenericServlet also includes log( ) methods that provide easy access to the logging functions from ServletContext.

The service( ) method is declared as abstract and must be overridden. Well-written servlets also override getServletInfo( ).

Class Summary

public abstract class GenericServlet implements Servlet, ServletConfig, java.io.Serializable { // Constructors public GenericServlet(); // Instance Methods public void destroy(); public String getInitParameter(String name); public Enumeration getInitParameterNames(); public ServletConfig getServletConfig(); public ServletContext getServletContext(); public String getServletInfo(); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required