img
Method
Description
void destroy( )
Called when the ser vlet is unloaded.
Ser vletConfig getSer vletConfig( )
Returns a ServletConfig object that contains any initialization
parameters.
String getSer vletInfo( )
Returns a string describing the ser vlet.
void init(Ser vletConfig sc)
Called when the ser vlet is initialized. Initialization
parameters for the ser vlet can be obtained from sc.
throws Ser vletException
An UnavailableException should be thrown if the
ser vlet cannot be initialized.
void ser vice(Ser vletRequest req,
Called to process a request from a client. The request from
Ser vletResponse res)
the client can be read from req. The response to the client
can be written to res. An exception is generated if a ser vlet
throws Ser vletException,
IOException
or IO problem occurs.
TABLE 31-1
The Methods Defined by Servlet
The Ser vletRequest Interface
The ServletRequest interface enables a servlet to obtain information about a client request.
Several of its methods are summarized in Table 31-3.
The Ser vletResponse Interface
The ServletResponse interface enables a servlet to formulate a response for a client. Several
of its methods are summarized in Table 31-4.
Method
Description
Object getAttribute(String attr)
Returns the value of the ser ver attribute named attr.
String getMimeType(String file)
Returns the MIME type of file.
String getRealPath(String vpath)
Returns the real path that corresponds to the vir tual
path vpath.
String getSer verInfo( )
Returns information about the ser ver.
void log(String s)
Writes s to the ser vlet log.
void log(String s, Throwable e)
Writes s and the stack trace for e to the ser vlet log.
void setAttribute(String attr, Object val)
Sets the attribute specified by attr to the value
passed in val.
TABLE 31-2
Various Methods Defined by ServletContext
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home