public abstract class GenericServlet extends java.lang.Object implements Servlet, ServletConfig, java.io.Serializable
In addition, GenericServlet implements ServletConfig to make it easier to get configuration information.
Servlet configuration looks like the following:
<servlet servlet-name='myservlet'
servlet-class='test.MyServlet'>
<init-param param1='value1'/>
<init-param param2='value2'/>
</servlet>
Constructor and Description |
---|
GenericServlet() |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Called when the servlet (and the application) shuts down.
|
java.lang.String |
getInitParameter(java.lang.String name)
Returns an initialization parameter.
|
java.util.Enumeration<java.lang.String> |
getInitParameterNames()
Enumerates all the initialization parameter.
|
ServletConfig |
getServletConfig()
Returns this servlet's configuration.
|
ServletContext |
getServletContext()
Returns the application (servlet context) that the servlet
belongs to.
|
java.lang.String |
getServletInfo()
Returns a string describing the servlet.
|
java.lang.String |
getServletName()
Returns the servlet name for this configuration.
|
void |
init()
Initialize the servlet.
|
void |
init(ServletConfig config)
Initialize the servlet.
|
void |
log(java.lang.String message)
Logs an error message in the application's log.
|
void |
log(java.lang.String message,
java.lang.Throwable cause)
Logs an error message and an exception trace in the application's log.
|
java.lang.String |
toString() |
public void init(ServletConfig config) throws ServletException
init()
instead.init
in interface Servlet
config
- the servlet's configurationServletException
public void init() throws ServletException
ServletException
public ServletConfig getServletConfig()
getServletConfig
in interface Servlet
public java.lang.String getServletName()
<servlet servlet-name='myservlet'
servlet-class='test.MyServlet'/>
getServletName
in interface ServletConfig
public java.lang.String getInitParameter(java.lang.String name)
<servlet servlet-name='myservlet'
servlet-class='test.MyServlet'>
<init-param param1='value1'/>
<init-param param2='value2'/>
</servlet>
getInitParameter
in interface ServletConfig
name
- of the parameterpublic java.util.Enumeration<java.lang.String> getInitParameterNames()
getInitParameterNames
in interface ServletConfig
public ServletContext getServletContext()
getServletContext
in interface ServletConfig
public java.lang.String getServletInfo()
getServletInfo
in interface Servlet
public void log(java.lang.String message)
public void log(java.lang.String message, java.lang.Throwable cause)
public void destroy()
public java.lang.String toString()
toString
in class java.lang.Object