img
Method
Description
Object getAttribute(String attr)
Returns the value of the attribute named attr.
String getCharacterEncoding( )
Returns the character encoding of the request.
int getContentLength( )
Returns the size of the request. The value ­1 is returned if the
size is unavailable.
String getContentType( )
Returns the type of the request. A null value is returned if the
type cannot be determined.
Ser vletInputStream getInputStream( )
Returns a ServletInputStream that can be used to read binar y
throws IOException
data from the request. An IllegalStateException is thrown if
getReader( ) has already been invoked for this request.
String getParameter(String pname)
Returns the value of the parameter named pname.
Enumeration getParameterNames( )
Returns an enumeration of the parameter names for this request.
String[ ] getParameterValues(String name) Returns an array containing values associated with the parameter
specified by name.
String getProtocol( )
Returns a description of the protocol.
Buf feredReader getReader( )
Returns a buf fered reader that can be used to read text from the
throws IOException
request. An IllegalStateException is thrown if getInputStream( )
has already been invoked for this request.
String getRemoteAddr( )
Returns the string equivalent of the client IP address.
String getRemoteHost( )
Returns the string equivalent of the client host name.
String getScheme( )
Returns the transmission scheme of the URL used for the request
(for example, "http", "ftp").
String getSer verName( )
Returns the name of the ser ver.
int getSer verPor t( )
Returns the por t number.
TABLE 31-3
Various Methods Defined by ServletRequest
The GenericSer vlet Class
The GenericServlet class provides implementations of the basic life cycle methods for a servlet.
GenericServlet implements the Servlet and ServletConfig interfaces. In addition, a method to
append a string to the server log file is available. The signatures of this method are shown here:
void log(String s)
void log(String s, Throwable e)
Here, s is the string to be appended to the log, and e is an exception that occurred.
Method
Description
String getCharacterEncoding( )
Returns the character encoding for the response.
Ser vletOutputStream
Returns a ServletOutputStream that can be used to write binar y data to the
getOutputStream( )
response. An IllegalStateException is thrown if getWriter( ) has already
throws IOException
been invoked for this request.
PrintWriter getWriter( )
Returns a PrintWriter that can be used to write character data to the
throws IOException
response. An IllegalStateException is thrown if getOutputStream( )
has already been invoked for this request.
void setContentLength(int size)
Sets the content length for the response to size.
void setContentType(String type) Sets the content type for the response to type.
TABLE 31-4
Various Methods Defined by ServletResponse
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home