<HTML>
<HEAD>
<TITLE>Servlet::GenericServlet - Servlet base class</TITLE>
<LINK REL="stylesheet" HREF="../../libservlet.css" TYPE="text/css">
<LINK REV="made" HREF="mailto:feedback@suse.de">
</HEAD>

<BODY>

<A NAME="__index__"></A>
<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#name">NAME</A></LI>
	<LI><A HREF="#synopsis">SYNOPSIS</A></LI>
	<LI><A HREF="#description">DESCRIPTION</A></LI>
	<LI><A HREF="#constructor">CONSTRUCTOR</A></LI>
	<LI><A HREF="#methods">METHODS</A></LI>
	<LI><A HREF="#see also">SEE ALSO</A></LI>
	<LI><A HREF="#author">AUTHOR</A></LI>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="name">NAME</A></H1>
<P>Servlet::GenericServlet - Servlet base class</P>
<P>
<HR>
<H1><A NAME="synopsis">SYNOPSIS</A></H1>
<PRE>
  # usually subclasses will be instantiated instead
  my $servlet = Servlet::GenericServlet-&gt;new();</PRE>
<PRE>
  $servlet-&gt;init($config);</PRE>
<PRE>
  for my $name ($getInitParameterNames()) {
      my $value = $servlet-&gt;getInitParameter($name);
  }</PRE>
<PRE>
  my $config = $servlet-&gt;getServletConfig();</PRE>
<PRE>
  my $context = $servlet-&gt;getServletContext();</PRE>
<PRE>
  my $info = $servlet-&gt;getServletInfo();</PRE>
<PRE>
  my $name = $servlet-&gt;getServletName();</PRE>
<PRE>
  $servlet-&gt;service($request, $response);</PRE>
<PRE>
  $servlet-&gt;log($message, $e);</PRE>
<PRE>
  $servlet-&gt;destroy();</PRE>
<P>
<HR>
<H1><A NAME="description">DESCRIPTION</A></H1>
<P>Defines a generic, protocol-independent servlet. To write an HTTP
servlet, extend <STRONG>Servlet::Http::HttpServlet</STRONG> instead.</P>
<P>Implements the <STRONG>Servlet::Servlet</STRONG> and <STRONG>Servlet::ServletConfig</STRONG>
interfaces. May be directly extended by a servlet, although it's more
common to extend a protocol-specific subclass.</P>
<P>To write a generic servlet, a developer need only override the
<A HREF="#item_service"><CODE>service()</CODE></A> method.</P>
<P>
<HR>
<H1><A NAME="constructor">CONSTRUCTOR</A></H1>
<DL>
<DT><STRONG><A NAME="item_new"><CODE>new()</CODE></A></STRONG><BR>
<DD>
Does nothing. All of the servlet initialization is done by the
<A HREF="#item_init"><CODE>init()</CODE></A> method.
<P></P></DL>
<P>
<HR>
<H1><A NAME="methods">METHODS</A></H1>
<DL>
<DT><STRONG><A NAME="item_destroy"><CODE>destroy()</CODE></A></STRONG><BR>
<DD>
Called by the servlet container to indicate to a servlet that the
servlet is being taken out of service.
<P></P>
<DT><STRONG><A NAME="item_getInitParameter"><CODE>getInitParameter($name)</CODE></A></STRONG><BR>
<DD>
Returns the value of the named initialization parameter, or <EM>undef</EM>
if the parameter does not exists.
<P>This method is supplied for convenience. It gets the value of the
named parameter from the servlet's config object.</P>
<P><STRONG>Parameters:</STRONG></P>
<DL>
<DT><STRONG><A NAME="item_%24name"><EM>$name</EM></A></STRONG><BR>
<DD>
the name of the parameter
<P></P></DL>
<DT><STRONG><A NAME="item_getParameterNames"><CODE>getParameterNames()</CODE></A></STRONG><BR>
<DD>
Returns an array containing the names of the servlet's initialization
parameters, or an empty array if the servlet has no initialization
parameters.
<P>This method is supplied for convenience. It gets the parameter names
from the servlet's config object.</P>
<P></P>
<DT><STRONG><A NAME="item_getServletConfig"><CODE>getServletConfig()</CODE></A></STRONG><BR>
<DD>
Returns this servlet's <STRONG>Servlet::ServletConfig</STRONG> object.
<P></P>
<DT><STRONG><A NAME="item_getServletContext"><CODE>getServletContext()</CODE></A></STRONG><BR>
<DD>
Returns the <STRONG>Servlet::ServletContext</STRONG> object representing the web
application in which the servlet is running.
<P>This method is supplied for convenience. It gets the context from the
servlet's config object.</P>
<P></P>
<DT><STRONG><A NAME="item_getServletInfo"><CODE>getServletInfo()</CODE></A></STRONG><BR>
<DD>
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.
<P></P>
<DT><STRONG><A NAME="item_getServletName"><CODE>getServletName()</CODE></A></STRONG><BR>
<DD>
Returns the name of this servlet instance.
<P></P>
<DT><STRONG><A NAME="item_init"><CODE>init([$config])</CODE></A></STRONG><BR>
<DD>
Called by the servlet container to indicate to a servlet that the
servlet is being placed into service.
<P>This implementation stores the config object it receives from the
servlet container for later use. When overriding this method, make
sure to call</P>
<PRE>
  $self-&gt;SUPER::init($config)</PRE>
<P><STRONG>Parameters:</STRONG></P>
<DL>
<DT><STRONG><A NAME="item_%24config"><EM>$config</EM></A></STRONG><BR>
<DD>
the <STRONG>Servlet::ServletConfig</STRONG> object that contains configuration
information for this servlet
<P></P></DL>
<P><STRONG>Throws:</STRONG></P>
<DL>
<DT><STRONG><A NAME="item_Servlet%3A%3AServletException"><STRONG>Servlet::ServletException</STRONG></A></STRONG><BR>
<DD>
if an exception occurs that interrupts the servlet's normal operation
<P></P></DL>
<DT><STRONG><A NAME="item_log">log($message, [$e])</A></STRONG><BR>
<DD>
Writes the specified message (and stack trace, if an optional
exception is specified) to the servlet log, prepended by the servlet's
name.
<P><STRONG>Parameters:</STRONG></P>
<DL>
<DT><STRONG><A NAME="item_%24message"><EM>$message</EM></A></STRONG><BR>
<DD>
the error message
<P></P>
<DT><STRONG><A NAME="item_%24e"><EM>$e</EM></A></STRONG><BR>
<DD>
an instance of <STRONG>Servlet::Util::Exception</STRONG> (optional)
<P></P></DL>
<DT><STRONG><A NAME="item_service">service($request, $response)</A></STRONG><BR>
<DD>
Called by the servlet container to allow the servlet to respond to a
request. Subclasses should override it.
<P><STRONG>Parameters:</STRONG></P>
<DL>
<DT><STRONG><A NAME="item_%24request"><EM>$request</EM></A></STRONG><BR>
<DD>
the <STRONG>Servlet::ServletRequest</STRONG> object that contains the client's
request
<P></P>
<DT><STRONG><A NAME="item_%24response"><EM>$response</EM></A></STRONG><BR>
<DD>
the <STRONG>Servlet::ServletResponse</STRONG> object that contains the servlet's
response
<P></P></DL>
<P><STRONG>Throws:</STRONG></P>
<DL>
<DT><STRONG><STRONG>Servlet::ServletException</STRONG></STRONG><BR>
<DD>
if an exception occurs that interferes with the servlet's normal
operation
<P></P>
<DT><STRONG><A NAME="item_Servlet%3A%3AUtil%3A%3AIOException"><STRONG>Servlet::Util::IOException</STRONG></A></STRONG><BR>
<DD>
if an input or output exception occurs
<P></P></DL>
</DL>
<P>
<HR>
<H1><A NAME="see also">SEE ALSO</A></H1>
<P><A HREF="../../api/Servlet/ServletConfig.html">the Servlet::ServletConfig manpage</A>,
<A HREF="../../api/Servlet/ServletContext.html">the Servlet::ServletContext manpage</A>,
<A HREF="../../api/Servlet/ServletException.html">the Servlet::ServletException manpage</A>,
<A HREF="../../api/Servlet/Util/Exception.html">the Servlet::Util::Exception manpage</A></P>
<P>
<HR>
<H1><A NAME="author">AUTHOR</A></H1>
<P>Brian Moseley, <A HREF="mailto:bcm@maz.org">bcm@maz.org</A></P>

</BODY>

</HTML>