javax.servlet.http.HttpServlet instead.
GenericServlet implements the Servlet
and ServletConfig interfaces. GenericServlet
may be directly extended by a servlet, although it's more common to extend
a protocol-specific subclass such as HttpServlet.
GenericServlet makes writing servlets
easier. It provides simple versions of the lifecycle methods
init and destroy and of the methods
in the ServletConfig interface. GenericServlet
also implements the log method, declared in the
ServletContext interface.
To write a generic servlet, you need only
override the abstract service method.
| Modifier and Type | Field and Description |
|---|---|
| private transient ServletConfig | |
| private static final String | |
| private static ResourceBundle |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | destroy()
Implements javax. |
| public String | Returns: String aString containing the value
of the initialization parametera name)String specifying the name
of the initialization parameterImplements javax. String containing the value of the named
initialization parameter, or null if the parameter does
not exist.
|
| public Enumeration | Returns: Enumeration an enumeration ofString
objects containing the names of
the servlet's initialization parametersImplements javax. Enumeration of String objects,
or an empty Enumeration if the servlet has no
initialization parameters.
|
| public ServletConfig | Returns: ServletConfig theServletConfig object
that initialized this servletImplements javax. ServletConfig object.
|
| public ServletContext | Returns: ServletContext theServletContext object
passed to this servlet by the init
methodImplements javax. ServletContext in which this servlet
is running.
|
| public String | Returns: String information about this servlet, by default an empty stringImplements javax. |
| public String | Returns: the name of this servlet instanceImplements javax. |
| public void | init(ServletConfig
the config)ServletConfig object
that contains configuration
information for this servletImplements javax. |
| public void | init()
A convenience method which can be overridden so that there's no need
to call |
| public void | |
| public void | |
| public abstract void | service(ServletRequest
the req, ServletResponse ServletRequest object
that contains the client's requestthe res)ServletResponse object
that will contain the servlet's responseRedeclares javax. |
| config | back to summary |
|---|---|
| private transient ServletConfig config | |
| LSTRING_FILE | back to summary |
|---|---|
| private static final String LSTRING_FILE | |
| lStrings | back to summary |
|---|---|
| private static ResourceBundle lStrings | |
| GenericServlet | back to summary |
|---|---|
| public GenericServlet() Does nothing. All of the servlet initialization
is done by one of the | |
| destroy | back to summary |
|---|---|
| public void destroy() Implements javax. Called by the servlet container to indicate to a servlet that the
servlet is being taken out of service. See | |
| getInitParameter | back to summary |
|---|---|
| public String getInitParameter(String name) Implements javax. Returns a This method is supplied for convenience. It gets the
value of the named parameter from the servlet's
| |
| getInitParameterNames | back to summary |
|---|---|
| public Enumeration Implements javax. Returns the names of the servlet's initialization parameters
as an This method is supplied for convenience. It gets the
parameter names from the servlet's
| |
| getServletConfig | back to summary |
|---|---|
| public ServletConfig getServletConfig() Implements javax. Returns this servlet's
| |
| getServletContext | back to summary |
|---|---|
| public ServletContext getServletContext() Implements javax. Returns a reference to the This method is supplied for convenience. It gets the
context from the servlet's
| |
| getServletInfo | back to summary |
|---|---|
| public String getServletInfo() Implements javax. Returns information about the servlet, such as
author, version, and copyright.
By default, this method returns an empty string. Override this method
to have it return a meaningful value. See
| |
| getServletName | back to summary |
|---|---|
| public String getServletName() Implements javax. Returns the name of this servlet instance.
See
| |
| init | back to summary |
|---|---|
| public void init(ServletConfig config) throws ServletException Implements javax. Called by the servlet container to indicate to a servlet that the
servlet is being placed into service. See This implementation stores the
| |
| init | back to summary |
|---|---|
| public void init() throws ServletException A convenience method which can be overridden so that there's no need
to call Instead of overriding
| |
| log | back to summary |
|---|---|
| public void log(String msg) Writes the specified message to a servlet log file, prepended by the
servlet's name. See
| |
| log | back to summary |
|---|---|
| public void log(String message, Throwable t) Writes an explanatory message and a stack trace
for a given | |
| service | back to summary |
|---|---|
| public abstract void service(ServletRequest req, ServletResponse res) throws ServletException, IOException Redeclares javax. Called by the servlet container to allow the servlet to respond to
a request. See This method is declared abstract so subclasses, such as
| |