javax.servlet
Class GenericServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
All Implemented Interfaces:
java.io.Serializable, Servlet, ServletConfig
Direct Known Subclasses:
BurlapServlet, CGIServlet, DeploymentServlet, EJBServlet, ErrorStatusServlet, FacesServletImpl, FastCGIServlet, FileServlet, FormLoginServlet, GenericCometServlet, HmtpServlet, HmuxLoadBalanceServlet, HttpProxyServlet, HttpServlet, JmtpServlet, JsfDeveloperAidServlet, ManagementServlet, RemoteFilesystemServlet, ResinStatusServlet, WebDavServlet, YadisServlet

public abstract class GenericServlet
extends java.lang.Object
implements Servlet, ServletConfig, java.io.Serializable

GenericServlet is a convenient abstract class for defining Servlets. Servlets which need more control than HttpServlet can extend GenericServlet.

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>
 

See Also:
Serialized Form

Constructor Summary
GenericServlet()
           
 
Method Summary
 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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.servlet.Servlet
service
 

Constructor Detail

GenericServlet

public GenericServlet()
Method Detail

init

public void init(ServletConfig config)
          throws ServletException
Initialize the servlet. Most servlets should override the zero parameter init() instead.

Specified by:
init in interface Servlet
Parameters:
config - the servlet's configuration
Throws:
ServletException

init

public void init()
          throws ServletException
Initialize the servlet. Servlets should override this method if they need any initialization like opening pooled database connections.

Throws:
ServletException

getServletConfig

public ServletConfig getServletConfig()
Returns this servlet's configuration.

Specified by:
getServletConfig in interface Servlet

getServletName

public java.lang.String getServletName()
Returns the servlet name for this configuration. For example, 'myservlet' in the following configuration:

 <servlet servlet-name='myservlet'
          servlet-class='test.MyServlet'/>
 

Specified by:
getServletName in interface ServletConfig

getInitParameter

public java.lang.String getInitParameter(java.lang.String name)
Returns an initialization parameter. Initialization parameters are defined in the servlet configuration (in resin.conf) as follows:

 <servlet servlet-name='myservlet'
          servlet-class='test.MyServlet'>
   <init-param param1='value1'/>
   <init-param param2='value2'/>
 </servlet>
 

Specified by:
getInitParameter in interface ServletConfig
Parameters:
name - of the parameter
Returns:
the init parameter value

getInitParameterNames

public java.util.Enumeration<java.lang.String> getInitParameterNames()
Enumerates all the initialization parameter.

Specified by:
getInitParameterNames in interface ServletConfig

getServletContext

public ServletContext getServletContext()
Returns the application (servlet context) that the servlet belongs to. The application provides several useful methods, e.g. including other files, forwarding, and translating physical paths.

Specified by:
getServletContext in interface ServletConfig

getServletInfo

public java.lang.String getServletInfo()
Returns a string describing the servlet.

Specified by:
getServletInfo in interface Servlet

log

public void log(java.lang.String message)
Logs an error message in the application's log.


log

public void log(java.lang.String message,
                java.lang.Throwable cause)
Logs an error message and an exception trace in the application's log.


destroy

public void destroy()
Called when the servlet (and the application) shuts down.

Specified by:
destroy in interface Servlet

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object