All Packages Class Hierarchy This Package Previous Next Index
Class javax.servlet.GenericServlet
java.lang.Object
|
+----javax.servlet.GenericServlet
- public abstract class GenericServlet
- extends Object
- implements Servlet, ServletConfig, Serializable
Abstract base class for all servlets.
- Version:
- Servlet API 2.0
-
GenericServlet()
- Does nothing.
-
destroy()
- Called by the server when it no longer needs the servlet.
-
getInitParameter(String)
- Gets a servlet's initialization parameter
-
getInitParameterNames()
- Gets all the initialization parameters
-
getServletConfig()
- Gets the servlet servletConfig class
-
getServletContext()
- Returns the servlets context
-
getServletInfo()
- The servlet programmer can put other additional info (version
number, etc) here.
-
init(ServletConfig)
- Initializes the servlet.
-
log(String)
- Writes the class name and a message to the log.
-
service(ServletRequest, ServletResponse)
- Called by the server every time it wants the servlet to handle
a request.
GenericServlet
public GenericServlet()
- Does nothing.
init
public void init(ServletConfig servletConfig) throws ServletException
- Initializes the servlet.
Called by the server exactly once during the lifetime of the servlet.
This method can be used to setup resources (connections to a
database for example) for this servlet.
Note that if a servlet overrides this method it should call
super.init(servletConfig)
otherwise the other methods in
GenericServlet are not garanteed to work.
- Parameters:
- servletConfig - This servlet configuration class
- Throws: ServletException
- If an error occurs
getServletContext
public ServletContext getServletContext()
- Returns the servlets context
- Returns:
- The context
getInitParameter
public String getInitParameter(String name)
- Gets a servlet's initialization parameter
- Parameters:
- name - the name of the wanted parameter
- Returns:
- the value of the wanted parameter.
null if the named parameter is not present.
getInitParameterNames
public Enumeration getInitParameterNames()
- Gets all the initialization parameters
- Returns:
- an Enumeration of all the parameters
log
public void log(String message)
- Writes the class name and a message to the log.
Calls
getServletContext().log()
.
- Parameters:
- message - the message to write
getServletInfo
public String getServletInfo()
- The servlet programmer can put other additional info (version
number, etc) here.
The Servlet 2.1 Spec says that this should return an empty string.
The Servlet 2.1 API says that this should return null unless overridden.
This version returns the servlet's class name which seems more usefull.
- Returns:
- The String holding the information
getServletConfig
public ServletConfig getServletConfig()
- Gets the servlet servletConfig class
- Returns:
- The servletConfig class
service
public abstract void service(ServletRequest request,
ServletResponse response) throws ServletException, IOException
- Called by the server every time it wants the servlet to handle
a request.
- Parameters:
- request - all the request information
- response - class to write all the response data to
- Throws: ServletException
- If an error occurs
- Throws: IOException
- If an error occurs
destroy
public void destroy()
- Called by the server when it no longer needs the servlet.
The servlet programmer should use this method to free all
the resources the servlet is holding.
This version does nothing because it has nothing to clean up.
Note that the the 2.1 Spec says that this should do nothing,
but the 2.1 API Doc says that it logs the destroy action.
All Packages Class Hierarchy This Package Previous Next Index