ServletRequest (Java(TM) EE 8 Specification APIs)
AsyncContext
getAsyncContext()
Object
getAttribute(String name)
Returns the value of the named attribute as an Object,
or null if no attribute of the given name exists.
Enumeration<String>
getAttributeNames()
Returns an Enumeration containing the
names of the attributes available to this request.
String
getCharacterEncoding()
Returns the name of the character encoding used in the body of this request.
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 ir is greater than Integer.MAX_VALUE.
long
getContentLengthLong()
Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known.
String
getContentType()
Returns the MIME type of the body of the request, or
null if the type is not known.
DispatcherType
getDispatcherType()
Gets the dispatcher type of this request.
ServletInputStream
getInputStream()
Retrieves the body of the request as binary data using
a ServletInputStream.
String
getLocalAddr()
Returns the Internet Protocol (IP) address of the interface on which the request was received.
Locale
getLocale()
Returns the preferred Locale that the client will
accept content in, based on the Accept-Language header.
Enumeration<Locale>
getLocales()
Returns an Enumeration of Locale objects
indicating, in decreasing order starting with the preferred locale, the
locales that are acceptable to the client based on the Accept-Language
header.
String
getLocalName()
Returns the host name of the Internet Protocol (IP) interface on which the request was received.
int
getLocalPort()
Returns the Internet Protocol (IP) port number of the interface on which the request was received.
String
getParameter(String name)
Returns the value of a request parameter as a String,
or null if the parameter does not exist.
Map<String,String[]>
getParameterMap()
Returns a java.util.Map of the parameters of this request.
Enumeration<String>
getParameterNames()
Returns an Enumeration of String
objects containing the names of the parameters contained
in this request.
String[]
getParameterValues(String name)
Returns an array of String objects containing
all of the values the given request parameter has, or
null if the parameter does not exist.
String
getProtocol()
Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.
BufferedReader
getReader()
Retrieves the body of the request as character data using
a BufferedReader.
String
getRealPath(String path)
String
getRemoteAddr()
Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
String
getRemoteHost()
Returns the fully qualified name of the client or the last proxy that sent the request.
int
getRemotePort()
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.
RequestDispatcher
getRequestDispatcher(String path)
Returns a RequestDispatcher object that acts as a wrapper for
the resource located at the given path.
String
getScheme()
Returns the name of the scheme used to make this request,
for example,
http, https, or ftp.
String
getServerName()
Returns the host name of the server to which the request was sent.
int
getServerPort()
Returns the port number to which the request was sent.
ServletContext
getServletContext()
Gets the servlet context to which this ServletRequest was last dispatched.
boolean
isAsyncStarted()
Checks if this request has been put into asynchronous mode.
boolean
isAsyncSupported()
Checks if this request supports asynchronous operation.
boolean
isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
void
removeAttribute(String name)
Removes an attribute from this request.
void
setAttribute(String name,
Object o)
Stores an attribute in this request.
void
setCharacterEncoding(String env)
Overrides the name of the character encoding used in the body of this request.
AsyncContext
startAsync()
Puts this request into asynchronous mode, and initializes its
AsyncContext with the original (unwrapped) ServletRequest
and ServletResponse objects.
AsyncContext
startAsync(ServletRequest servletRequest,
ServletResponse servletResponse)
Puts this request into asynchronous mode, and initializes its
AsyncContext with the given request and response objects.