jakarta.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 final ResourceBundle | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | destroy()
Implements jakarta. Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. |
| public String | Returns: String aString containing the value of the initialization parametera name)String specifying the name of the initialization parameterImplements jakarta. Returns a |
| public Enumeration | Returns: Enumeration an enumeration ofString objects containing the names of the servlet's
initialization parametersImplements jakarta. Returns the names of the servlet's initialization parameters as an |
| public ServletConfig | Returns: ServletConfig theServletConfig object that initialized this servletImplements jakarta. Returns this servlet's |
| public ServletContext | Returns: ServletContext theServletContext object passed to this servlet by the init methodImplements jakarta. Returns a reference to the |
| public String | Returns: String information about this servlet, by default an empty stringImplements jakarta. Returns information about the servlet, such as author, version, and copyright. |
| public String | Returns: the name of this servlet instanceImplements jakarta. Returns the name of this servlet instance. |
| public void | init(ServletConfig
the config)ServletConfig object that contains configuration information for this servletImplements jakarta. Called by the servlet container to indicate to a servlet that the servlet is being placed into service. |
| 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 jakarta. Called by the servlet container to allow the servlet to respond to a request. |
| 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 final ResourceBundle lStrings | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| 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 jakarta. 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 jakarta. 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 jakarta. 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 jakarta. Returns this servlet's
| |
| getServletContext | back to summary |
|---|---|
| public ServletContext getServletContext() Implements jakarta. 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 jakarta. 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 jakarta. Returns the name of this servlet instance. See | |
| init | back to summary |
|---|---|
| public void init(ServletConfig config) throws ServletException Implements jakarta. 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 jakarta. Called by the servlet container to allow the servlet to respond to a request. See
This method is declared abstract so subclasses, such as
| |