All Packages Class Hierarchy This Package Previous Next Index
Interface javax.servlet.ServletRequest
- public interface ServletRequest
This interface is for getting data from the client to the servlet
for a service request. Network service developers implement the
ServletRequest interface. The methods are then used by servlets
when the service method is executed; the ServletRequest object is
passed as an argument to the service method.
Some of the data provided by the ServletRequest object includes
parameter names and values, attributes, and an input stream.
Subclasses of ServletRequest can provide additional
protocol-specific data. For example, HTTP data is provided by the
interface HttpServletRequest, which extends ServletRequest. This
framework provides the servlet's only access to this data.
- See Also:
- HttpServletRequest
-
getAttribute(String)
-
Returns the value of the named attribute of the request, or
null if the attribute does not exist.
-
getContentLength()
- Returns the size of the request entity data, or -1 if not known.
-
getContentType()
- Returns the Internet Media Type of the request entity data, or
null if not known.
-
getInputStream()
- Returns an input stream for reading the request body.
-
getParameter(String)
- Returns a string containing the lone value of the specified
parameter, or null if the parameter does not exist.
-
getParameterNames()
- Returns the parameter names for this request as an enumeration
of strings, or an empty enumeration if there are no parameters
or the input stream is empty.
-
getParameterValues(String)
-
Returns the values of the specified parameter for the request as
an array of strings, or null if the named parameter does not
exist.
-
getProtocol()
- Returns the protocol and version of the request as a string of
the form
<protocol>/<major version>.<minor
version>
.
-
getRealPath(String)
- Applies alias rules to the specified virtual path and returns
the corresponding real path, or null if the translation can not
be performed for any reason.
-
getRemoteAddr()
- Returns the IP address of the agent that sent the request.
-
getRemoteHost()
- Returns the fully qualified host name of the agent that sent the
request.
-
getScheme()
- Returns the scheme of the URL used in this request, for example
"http", "https", or "ftp".
-
getServerName()
- Returns the host name of the server that received the request.
-
getServerPort()
- Returns the port number on which this request was received.
getContentLength
public abstract int getContentLength()
- Returns the size of the request entity data, or -1 if not known.
Same as the CGI variable CONTENT_LENGTH.
getContentType
public abstract String getContentType()
- Returns the Internet Media Type of the request entity data, or
null if not known. Same as the CGI variable CONTENT_TYPE.
getProtocol
public abstract String getProtocol()
- Returns the protocol and version of the request as a string of
the form
<protocol>/<major version>.<minor
version>
. Same as the CGI variable SERVER_PROTOCOL.
getScheme
public abstract String getScheme()
- Returns the scheme of the URL used in this request, for example
"http", "https", or "ftp". Different schemes have different
rules for constructing URLs, as noted in RFC 1738. The URL used
to create a request may be reconstructed using this scheme, the
server name and port, and additional information such as URIs.
getServerName
public abstract String getServerName()
- Returns the host name of the server that received the request.
Same as the CGI variable SERVER_NAME.
getServerPort
public abstract int getServerPort()
- Returns the port number on which this request was received.
Same as the CGI variable SERVER_PORT.
getRemoteAddr
public abstract String getRemoteAddr()
- Returns the IP address of the agent that sent the request.
Same as the CGI variable REMOTE_ADDR.
getRemoteHost
public abstract String getRemoteHost()
- Returns the fully qualified host name of the agent that sent the
request. Same as the CGI variable REMOTE_HOST.
getRealPath
public abstract String getRealPath(String path)
- Applies alias rules to the specified virtual path and returns
the corresponding real path, or null if the translation can not
be performed for any reason. For example, an HTTP servlet would
resolve the path using the virtual docroot, if virtual hosting
is enabled, and with the default docroot otherwise. Calling
this method with the string "/" as an argument returns the
document root.
- Parameters:
- path - the virtual path to be translated to a real path
getInputStream
public abstract ServletInputStream getInputStream() throws IOException
- Returns an input stream for reading the request body.
getParameter
public abstract String getParameter(String name)
- Returns a string containing the lone value of the specified
parameter, or null if the parameter does not exist. For example,
in an HTTP servlet this method would return the value of the
specified query string parameter. Servlet writers should use
this method only when they are sure that there is only one value
for the parameter. If the parameter has (or could have)
multiple values, servlet writers should use
getParameterValues. If a multiple valued parameter name is
passed as an argument, the return value is implementation
dependent.
- Parameters:
- name - the name of the parameter whose value is required.
- See Also:
- getParameterValues
getParameterValues
public abstract String[] getParameterValues(String name)
- Returns the values of the specified parameter for the request as
an array of strings, or null if the named parameter does not
exist. For example, in an HTTP servlet this method would return
the values of the specified query string or posted form as an
array of strings.
- Parameters:
- name - the name of the parameter whose value is required.
- See Also:
- getParameter
getParameterNames
public abstract Enumeration getParameterNames()
- Returns the parameter names for this request as an enumeration
of strings, or an empty enumeration if there are no parameters
or the input stream is empty. The input stream would be empty
if all the data had been read from the stream returned by the
method getInputStream.
getAttribute
public abstract Object getAttribute(String name)
- Returns the value of the named attribute of the request, or
null if the attribute does not exist. This method allows
access to request information not already provided by the other
methods in this interface. Attribute names should follow the
same convention as package names. The package names java.*,
and javax.* are reserved for use by Javasoft, and com.sun.* is
reserved for use by Sun Microsystems.
- Parameters:
- name - the name of the attribute whose value is required
All Packages Class Hierarchy This Package Previous Next Index