ServletRequest object and passes
it as an argument to the servlet's service method.
A ServletRequest object provides data including
parameter name and values, attributes, and an input stream.
Interfaces that extend ServletRequest can provide
additional protocol-specific data (for example, HTTP data is
provided by javax..
javax.servlet.http.HttpServletRequest
| Modifier and Type | Method and Description |
|---|---|
| public Object | Returns: anObject containing the value
of the attribute, or null if the attribute does not exista name)String specifying the name of
the attributeReturns the value of the named attribute as an |
| public Enumeration | Returns: anEnumeration of strings
containing the names of the request's attributesReturns an |
| public String | Returns: aString containing the name of
the chararacter encoding, or null
if the request does not specify a character encodingReturns the name of the character encoding used in the body of this request. |
| public int | Returns: an integer containing the length of the request body or -1 if the length is not knownReturns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known. |
| public String | Returns: aString containing the name
of the MIME type of the request, or null if the type is not knownReturns the MIME type of the body of the request, or
|
| public ServletInputStream | Returns: aServletInputStream object containing
the body of the requestRetrieves the body of the request as binary data using
a |
| public String | Returns: aString containing the
IP address on which the request was received.Returns the Internet Protocol (IP) address of the interface on which the request was received. |
| public Locale | Returns: the preferredLocale for the clientReturns the preferred |
| public Enumeration | Returns: anEnumeration of preferred
Locale objects for the clientReturns an |
| public String | Returns: aString containing the host
name of the IP on which the request was received.Returns the host name of the Internet Protocol (IP) interface on which the request was received. |
| public int | Returns: an integer specifying the port numberReturns the Internet Protocol (IP) port number of the interface on which the request was received. |
| public String | Returns: aString representing the
single value of the parametera name)String specifying the
name of the parameterReturns the value of a request parameter as a |
| public Map | Returns: an immutable java.util.Map containing parameter names as keys and parameter values as map values. The keys in the parameter map are of type String. The values in the parameter map are of type String array.Returns a java.util.Map of the parameters of this request. |
| public Enumeration | Returns: anEnumeration of String
objects, each String containing
the name of a request parameter; or an
empty Enumeration if the
request has no parametersReturns an |
| public String[] | Returns: an array ofString objects
containing the parameter's valuesa name)String containing the name of
the parameter whose value is requestedReturns an array of |
| public String | Returns: aString containing the protocol
name and version numberReturns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1. |
| public BufferedReader | Returns: aBufferedReader containing the body of the requestRetrieves the body of the request as character data using
a |
| public String | getRealPath(String path)
Deprecated
As of Version 2.1 of the Java Servlet API,
use
ServletContext#getRealPath instead.
|
| public String | Returns: aString containing the
IP address of the client that sent the requestReturns the Internet Protocol (IP) address of the client or last proxy that sent the request. |
| public String | Returns: aString containing the fully
qualified name of the clientReturns the fully qualified name of the client or the last proxy that sent the request. |
| public int | getRemotePort()
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request. |
| public RequestDispatcher | Returns: aRequestDispatcher object that acts as a
wrapper for the resource at the specified path, or null
if the servlet container cannot return a
RequestDispatchera path)String specifying the pathname to the
resource. If it is relative, it must be relative against the
current servlet.Returns a |
| public String | Returns: aString containing the name
of the scheme used to make this requestReturns the name of the scheme used to make this request,
for example,
|
| public String | Returns: aString containing the name
of the serverReturns the host name of the server to which the request was sent. |
| public int | Returns: an integer specifying the port numberReturns the port number to which the request was sent. |
| public boolean | Returns: a boolean indicating if the request was made using a secure channelReturns a boolean indicating whether this request was made using a secure channel, such as HTTPS. |
| public void | removeAttribute(String
a name)String specifying
the name of the attribute to removeRemoves an attribute from this request. |
| public void | setAttribute(String
a name, Object String specifying the name of the attributethe o)Object to be storedStores an attribute in this request. |
| public void | setCharacterEncoding(String
a env)String containing the name of
the chararacter encoding.Overrides the name of the character encoding used in the body of this request. |
| getAttribute | back to summary |
|---|---|
| public Object getAttribute(String name) Returns the value of the named attribute as an Attributes can be set two ways. The servlet container may set
attributes to make available custom information about a request.
For example, for requests made using HTTPS, the attribute
Attribute names should follow the same conventions as package
names. This specification reserves names matching | |
| getAttributeNames | back to summary |
|---|---|
| public Enumeration Returns an
| |
| getCharacterEncoding | back to summary |
|---|---|
| public String getCharacterEncoding() Returns the name of the character encoding used in the body of this
request. This method returns
| |
| getContentLength | back to summary |
|---|---|
| public int getContentLength() Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known. For HTTP servlets, same as the value of the CGI variable CONTENT_LENGTH.
| |
| getContentType | back to summary |
|---|---|
| public String getContentType() Returns the MIME type of the body of the request, or
| |
| getInputStream | back to summary |
|---|---|
| public ServletInputStream getInputStream() throws IOException Retrieves the body of the request as binary data using
a
| |
| getLocalAddr | back to summary |
|---|---|
| public String getLocalAddr() Returns the Internet Protocol (IP) address of the interface on which the request was received.
| |
| getLocale | back to summary |
|---|---|
| public Locale getLocale() Returns the preferred
| |
| getLocales | back to summary |
|---|---|
| public Enumeration Returns an
| |
| getLocalName | back to summary |
|---|---|
| public String getLocalName() Returns the host name of the Internet Protocol (IP) interface on which the request was received.
| |
| getLocalPort | back to summary |
|---|---|
| public int getLocalPort() Returns the Internet Protocol (IP) port number of the interface on which the request was received.
| |
| getParameter | back to summary |
|---|---|
| public String getParameter(String name) Returns the value of a request parameter as a You should only use this method when you are sure the
parameter has only one value. If the parameter might have
more than one value, use If you use this method with a multivalued
parameter, the value returned is equal to the first value
in the array returned by If the parameter data was sent in the request body, such as occurs
with an HTTP POST request, then reading the body directly via
| |
| getParameterMap | back to summary |
|---|---|
| public Map Returns a java.util.Map of the parameters of this request. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.
| |
| getParameterNames | back to summary |
|---|---|
| public Enumeration Returns an
| |
| getParameterValues | back to summary |
|---|---|
| public String[] getParameterValues(String name) Returns an array of If the parameter has a single value, the array has a length of 1.
| |
| getProtocol | back to summary |
|---|---|
| public String getProtocol() Returns the name and version of the protocol the request uses
in the form protocol/majorVersion.minorVersion, for
example, HTTP/1.1. For HTTP servlets, the value
returned is the same as the value of the CGI variable
| |
| getReader | back to summary |
|---|---|
| public BufferedReader getReader() throws IOException Retrieves the body of the request as character data using
a
| |
| getRealPath | back to summary |
|---|---|
| public String getRealPath(String path)
Deprecated As of Version 2.1 of the Java Servlet API,
use | |
| getRemoteAddr | back to summary |
|---|---|
| public String getRemoteAddr() Returns the Internet Protocol (IP) address of the client
or last proxy that sent the request.
For HTTP servlets, same as the value of the
CGI variable
| |
| getRemoteHost | back to summary |
|---|---|
| public String getRemoteHost() Returns the fully qualified name of the client
or the last proxy that sent the request.
If the engine cannot or chooses not to resolve the hostname
(to improve performance), this method returns the dotted-string form of
the IP address. For HTTP servlets, same as the value of the CGI variable
| |
| getRemotePort | back to summary |
|---|---|
| public int getRemotePort() Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.
| |
| getRequestDispatcher | back to summary |
|---|---|
| public RequestDispatcher getRequestDispatcher(String path) Returns a The pathname specified may be relative, although it cannot extend
outside the current servlet context. If the path begins with
a "/" it is interpreted as relative to the current context root.
This method returns The difference between this method and
| |
| getScheme | back to summary |
|---|---|
| public String getScheme() Returns the name of the scheme used to make this request,
for example,
| |
| getServerName | back to summary |
|---|---|
| public String getServerName() Returns the host name of the server to which the request was sent.
It is the value of the part before ":" in the
| |
| getServerPort | back to summary |
|---|---|
| public int getServerPort() Returns the port number to which the request was sent.
It is the value of the part after ":" in the
| |
| isSecure | back to summary |
|---|---|
| public boolean isSecure() Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
| |
| removeAttribute | back to summary |
|---|---|
| public void removeAttribute(String name) Removes an attribute from this request. This method is not generally needed as attributes only persist as long as the request is being handled. Attribute names should follow the same conventions as
package names. Names beginning with
| |
| setAttribute | back to summary |
|---|---|
| public void setAttribute(String name, Object o) Stores an attribute in this request.
Attributes are reset between requests. This method is most
often used in conjunction with Attribute names should follow the same conventions as
package names. Names beginning with | |
| setCharacterEncoding | back to summary |
|---|---|
| public void setCharacterEncoding(String env) throws UnsupportedEncodingException Overrides the name of the character encoding used in the body of this request. This method must be called prior to reading request parameters or reading input using getReader().
| |