img
The following table summarizes the core classes that are provided in the javax.servlet
package:
Class
Description
GenericSer vlet
Implements the Servlet and ServletConfig inter faces.
Ser vletInputStream
Provides an input stream for reading requests from a client.
Ser vletOutputStream
Provides an output stream for writing responses to a client.
Ser vletException
Indicates a ser vlet error occurred.
UnavailableException
Indicates a ser vlet is unavailable.
Let us examine these interfaces and classes in more detail.
The Ser vlet Interface
All servlets must implement the Servlet interface. It declares the init( ), service( ), and destroy( )
methods that are called by the server during the life cycle of a servlet. A method is also provided
that allows a servlet to obtain any initialization parameters. The methods defined by Servlet
are shown in Table 31-1.
The init( ), service( ), and destroy( ) methods are the life cycle methods of the servlet.
These are invoked by the server. The getServletConfig( ) method is called by the servlet to
obtain initialization parameters. A servlet developer overrides the getServletInfo( ) method
to provide a string with useful information (for example, author, version, date, copyright).
This method is also invoked by the server.
The Ser vletConfig Interface
The ServletConfig interface allows a servlet to obtain configuration data when it is loaded.
The methods declared by this interface are summarized here:
Method
Description
Ser vletContext getSer vletContext( )
Returns the context for this ser vlet.
String getInitParameter(String param)
Returns the value of the initialization parameter
named param.
Enumeration getInitParameterNames( )
Returns an enumeration of all initialization parameter
names.
String getSer vletName( )
Returns the name of the invoking ser vlet.
The Ser vletContext Interface
The ServletContext interface enables servlets to obtain information about their environment.
Several of its methods are summarized in Table 31-2.
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home