public interface ServletRequest
Modifier and Type | Method and Description |
---|---|
AsyncContext |
getAsyncContext()
Returns the current context for asynchronous operation.
|
java.lang.Object |
getAttribute(java.lang.String name)
Gets a named attribute's value.
|
java.util.Enumeration |
getAttributeNames()
Gets an Enumeration of all the attribute names.
|
java.lang.String |
getCharacterEncoding()
Gets the character encoding of the request data.
|
int |
getContentLength()
Gets the size in bytes of the request
|
java.lang.String |
getContentType()
Gets the mime type of the request
|
DispatcherType |
getDispatcherType()
Returns the dispatcher type of this request.
|
ServletInputStream |
getInputStream()
Creates an inputstream for servlets to read client request data from.
|
java.lang.String |
getLocalAddr()
Returns the IP address of the interface on which the request was
received.
|
java.util.Locale |
getLocale()
get the locale associated with the request.
|
java.util.Enumeration |
getLocales()
get all the locales associated with the request.
|
java.lang.String |
getLocalName()
Returns the DNS hostname of the IP interface on which the request was
received.
|
int |
getLocalPort()
Returns the port number of the interface on which the request was
received.
|
java.lang.String |
getParameter(java.lang.String name)
Gets the value of a named requestparameter.
|
java.util.Map |
getParameterMap()
Gets a Map of all the parameters contained within this request
|
java.util.Enumeration |
getParameterNames()
Gets all parameter names.
|
java.lang.String[] |
getParameterValues(java.lang.String name)
Gets an array of Strings containing all the request parameter's
values whose name matches
name . |
java.lang.String |
getProtocol()
Gets the protocol of the request as Proto/Major.Minor
("HTTP/1.1").
|
java.io.BufferedReader |
getReader()
Creates an BufferedReader for servlets to read client request
data from.
|
java.lang.String |
getRealPath(java.lang.String path)
Deprecated.
Should use getRealPath from the current ServletContext.
|
java.lang.String |
getRemoteAddr()
Gets the ip address of the client that sent the request
|
java.lang.String |
getRemoteHost()
Gets the hostname of the client that sent the request.
|
int |
getRemotePort()
Returns the IP source port of the client that sent the request.
|
RequestDispatcher |
getRequestDispatcher(java.lang.String path)
get a means of dispatching to the specified path.
|
java.lang.String |
getScheme()
Gets the scheme of the request as defined by RFC 1783
("ftp", "http", "gopher", "news").
|
java.lang.String |
getServerName()
Get the name of the server receiving the request
|
int |
getServerPort()
Gets the portnumber the server reveiving the request is running on.
|
ServletContext |
getServletContext()
Returns the context to which this request was last dispatched.
|
boolean |
isAsyncStarted()
Indicates whether this request has been put into asynchronous mode.
|
boolean |
isAsyncSupported()
Indicates whether asynchronous mode is supported for this request.
|
boolean |
isSecure()
has the request arrived under secure conditions?
A secure condition might be an encrypted channel, for
example SSL.
|
void |
removeAttribute(java.lang.String name)
remove the specified attribute.
|
void |
setAttribute(java.lang.String name,
java.lang.Object o)
Puts a named object into the
ServletRequest . |
void |
setCharacterEncoding(java.lang.String enc)
Sets the name of the character encoding used for the body
of this request
|
AsyncContext |
startAsync()
Put this request into asynchronous mode.
|
AsyncContext |
startAsync(ServletRequest request,
ServletResponse response)
Put this request into asynchronous mode using the specified
request/response pair.
|
java.lang.Object getAttribute(java.lang.String name)
Note that the Servlet 2.1 API Documentation mentions some predefined attribute names, but the Servlet Spec does not mention them. I (MJW) am not sure if they are platform specific (JWS) or not.
name
- the attribute namejava.util.Enumeration getAttributeNames()
java.lang.String getCharacterEncoding()
void setCharacterEncoding(java.lang.String enc) throws java.io.UnsupportedEncodingException
enc
- a String containing the name of the character encodingjava.io.UnsupportedEncodingException
- if the provided name is not
a valid encoding schemeint getContentLength()
java.lang.String getContentType()
ServletInputStream getInputStream() throws java.io.IOException
java.io.IOException
- if an i/o related error occuredjava.lang.IllegalStateException
- if getReader
was already
called on this request.getReader()
java.lang.String getParameter(java.lang.String name)
getParameterValues
should be used.
If there are more than one values associated with the parameter this
method will only return the first value as return by
getParameterValues
is returned.
see javax.servlet.ServletRequest.getParameterValues()name
- the name of the parameter whose value we wantjava.util.Enumeration getParameterNames()
Note that the Servlet API 2.1 documentation says that this returns an empty Enumeration if the input stream is empty, but this is not mandated by the Servlet Spec.
java.lang.String[] getParameterValues(java.lang.String name)
name
.name
- the parameter namejava.util.Map getParameterMap()
java.lang.String getProtocol()
java.lang.String getScheme()
java.lang.String getServerName()
int getServerPort()
java.io.BufferedReader getReader() throws java.io.IOException
java.io.IOException
- if an i/o related error occuredjava.lang.IllegalStateException
- if getInputStream
was
already called on this request.java.io.UnsupportedEncodingException
- if the character
encoding cannot be decoded.getInputStream()
java.lang.String getRemoteAddr()
java.lang.String getRemoteHost()
void setAttribute(java.lang.String name, java.lang.Object o)
ServletRequest
.
Can be used to communicate with other servlets if this
ServletRequest
is passed to another servlet through a
RequestDispatcher
.
The names used must follow the conventions used for naming java
packages.name
- - which is used to refer to this objectobject
- - which should be returned when somebody calls
getAttribute(name)
getAttribute(java.lang.String)
,
RequestDispatcher
void removeAttribute(java.lang.String name)
name
- the name of the attribute to be removedjava.util.Locale getLocale()
java.util.Enumeration getLocales()
boolean isSecure()
RequestDispatcher getRequestDispatcher(java.lang.String path)
path
- if relative it will be resolvedjava.lang.String getRealPath(java.lang.String path)
path
- the path which requires translatingServletContext.getRealPath(java.lang.String)
int getRemotePort()
java.lang.String getLocalName() throws java.io.IOException
java.io.IOException
java.lang.String getLocalAddr() throws java.io.IOException
java.io.IOException
int getLocalPort() throws java.io.IOException
java.io.IOException
ServletContext getServletContext()
AsyncContext startAsync() throws java.lang.IllegalStateException
AsyncContext.complete()
has been called.java.lang.IllegalStateException
AsyncContext startAsync(ServletRequest request, ServletResponse response) throws java.lang.IllegalStateException
AsyncContext.complete()
has been called.java.lang.IllegalStateException
boolean isAsyncStarted()
boolean isAsyncSupported()
AsyncContext getAsyncContext()
java.lang.IllegalStateException
- if this request has not been put into
asynchronous mode.DispatcherType getDispatcherType()