public class HttpServletRequestImpl extends ServletRequestImpl implements javax.servlet.http.HttpServletRequest
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
authType
The authentication type used for this request.
|
protected java.lang.String |
contextPath
The context path for this request.
|
protected java.util.ArrayList |
cookies
The set of cookies associated with this Request.
|
protected java.text.SimpleDateFormat[] |
formats
The set of SimpleDateFormat formats to use in getDateHeader().
|
protected java.util.HashMap |
headers
The HTTP headers associated with this Request, keyed by name.
|
protected java.lang.String |
method
The request method associated with this Request.
|
private java.util.Map |
parameters
The parameters
|
protected java.lang.String |
pathInfo
The path information for this request.
|
protected java.lang.String |
queryString
The query string for this request.
|
protected boolean |
requestedSessionCookie
Was the requested session ID received in a cookie?
|
protected java.lang.String |
requestedSessionId
The requested session ID (if any) for this request.
|
protected boolean |
requestedSessionURL
Was the requested session ID received in a URL?
|
protected java.lang.String |
requestURI
The request URI associated with this request.
|
protected java.lang.String |
servletPath
The servlet path for this request.
|
protected HttpSessionImpl |
session
The currently active session for this request.
|
protected java.security.Principal |
userPrincipal
The Principal who has been authenticated for this Request.
|
attributes, authorization, characterEncoding, contentLength, contentType, defaultLocale, input, locales, protocol, reader, remoteAddr, remoteHost, scheme, secure, serverName, serverPort, servletContext, stream
Constructor and Description |
---|
HttpServletRequestImpl(javax.servlet.ServletContext servletContext) |
Modifier and Type | Method and Description |
---|---|
void |
addCookie(javax.servlet.http.Cookie cookie)
Add a Cookie to the set of Cookies associated with this Request.
|
void |
addHeader(java.lang.String name,
java.lang.String value)
Add a Header to the set of Headers associated with this Request.
|
void |
clearCookies()
Clear the collection of Cookies associated with this Request.
|
void |
clearHeaders()
Clear the collection of Headers associated with this Request.
|
java.lang.String |
getAuthType()
Return the authentication type used for this Request.
|
java.lang.String |
getContextPath()
Return the portion of the request URI used to select the Context
of the Request.
|
javax.servlet.http.Cookie[] |
getCookies()
Return the set of Cookies received with this Request.
|
long |
getDateHeader(java.lang.String name)
Return the value of the specified date header, if any; otherwise
return -1.
|
java.lang.String |
getHeader(java.lang.String name)
Return the first value of the specified header, if any; otherwise,
return
null |
java.util.Enumeration |
getHeaderNames()
Return the names of all headers received with this request.
|
java.util.Enumeration |
getHeaders(java.lang.String name)
Return all of the values of the specified header, if any; otherwise,
return an empty enumeration.
|
int |
getIntHeader(java.lang.String name)
Return the value of the specified header as an integer, or -1 if there
is no such header for this request.
|
java.lang.String |
getMethod()
Return the HTTP request method used in this Request.
|
java.util.Map |
getParameterMap()
Returns a
Map of the parameters of this request. |
java.lang.String |
getPathInfo()
Return the path information associated with this Request.
|
java.lang.String |
getPathTranslated()
Return the extra path information for this request, translated
to a real path.
|
java.lang.String |
getQueryString()
Return the query string associated with this request.
|
java.lang.String |
getRemoteUser()
Return the name of the remote user that has been authenticated
for this Request.
|
java.lang.String |
getRequestedSessionId()
Return the session identifier included in this request, if any.
|
java.lang.String |
getRequestURI()
Return the request URI for this request.
|
java.lang.StringBuffer |
getRequestURL()
Reconstructs the URL the client used to make the request.
|
java.lang.String |
getServletPath()
Return the portion of the request URI used to select the servlet
that will process this request.
|
javax.servlet.http.HttpSession |
getSession()
Return the session associated with this Request, creating one
if necessary.
|
javax.servlet.http.HttpSession |
getSession(boolean create)
Return the session associated with this Request, creating one
if necessary and requested.
|
java.security.Principal |
getUserPrincipal()
Return the principal that has been authenticated for this Request.
|
boolean |
isRequestedSessionIdFromCookie()
Return
true if the session identifier included in this
request came from a cookie. |
boolean |
isRequestedSessionIdFromUrl()
Deprecated.
As of Version 2.1 of the Java Servlet API, use
isRequestedSessionIdFromURL() instead. |
boolean |
isRequestedSessionIdFromURL()
Return
true if the session identifier included in this
request came from the request URI. |
boolean |
isRequestedSessionIdValid()
Return
true if the session identifier included in this
request identifies a valid session. |
boolean |
isUserInRole(java.lang.String role)
Return
true if the authenticated user principal
possesses the specified role name. |
void |
setAuthType(java.lang.String authType)
Set the authentication type used for this request, if any; otherwise
set the type to
null . |
void |
setContextPath(java.lang.String path)
Set the context path for this Request.
|
void |
setMethod(java.lang.String method)
Set the HTTP request method used for this Request.
|
void |
setPathInfo(java.lang.String path)
Set the path information for this Request.
|
void |
setQueryString(java.lang.String query)
Set the query string for this Request.
|
void |
setRequestedSessionCookie(boolean flag)
Set a flag indicating whether or not the requested session ID for this
request came in through a cookie.
|
void |
setRequestedSessionId(java.lang.String id)
Set the requested session ID for this request.
|
void |
setRequestedSessionURL(boolean flag)
Set a flag indicating whether or not the requested session ID for this
request came in through a URL.
|
void |
setRequestURI(java.lang.String uri)
Set the unparsed request URI for this Request.
|
void |
setServletPath(java.lang.String path)
Set the servlet path for this Request.
|
void |
setUserPrincipal(java.security.Principal principal)
Set the Principal who has been authenticated for this Request.
|
addLocale, createInputStream, finishRequest, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocale, getLocales, getParameter, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRequestDispatcher, getScheme, getServerName, getServerPort, getStream, isSecure, log, log, removeAttribute, setAttribute, setCharacterEncoding, setContentLength, setContentType, setProtocol, setRemoteAddr, setRemoteHost, setScheme, setSecure, setServerName, setServerPort, setStream
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocale, getLocales, getParameter, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding
protected java.lang.String authType
protected java.lang.String contextPath
protected java.util.ArrayList cookies
protected java.text.SimpleDateFormat[] formats
protected java.util.HashMap headers
protected java.lang.String method
protected java.lang.String pathInfo
protected java.lang.String queryString
protected boolean requestedSessionCookie
protected java.lang.String requestedSessionId
protected boolean requestedSessionURL
protected java.lang.String requestURI
protected java.lang.String servletPath
protected HttpSessionImpl session
protected java.security.Principal userPrincipal
private java.util.Map parameters
public HttpServletRequestImpl(javax.servlet.ServletContext servletContext)
public void addCookie(javax.servlet.http.Cookie cookie)
cookie
- The new cookiepublic void addHeader(java.lang.String name, java.lang.String value)
name
- The new header namevalue
- The new header valuepublic void clearCookies()
public void clearHeaders()
public void setAuthType(java.lang.String authType)
null
. Typical values are "BASIC",
"DIGEST", or "SSL".authType
- The authentication type usedpublic void setContextPath(java.lang.String path)
path
- The context pathpublic void setMethod(java.lang.String method)
method
- The request methodpublic void setPathInfo(java.lang.String path)
path
- The path informationpublic void setQueryString(java.lang.String query)
query
- The query stringpublic void setRequestedSessionCookie(boolean flag)
flag
- The new flagpublic void setRequestedSessionId(java.lang.String id)
id
- The new session idpublic void setRequestedSessionURL(boolean flag)
flag
- The new flagpublic void setRequestURI(java.lang.String uri)
uri
- The request URIpublic void setServletPath(java.lang.String path)
path
- The servlet pathpublic void setUserPrincipal(java.security.Principal principal)
getRemoteUser()
method.principal
- The user Principalpublic java.lang.String getAuthType()
getAuthType
in interface javax.servlet.http.HttpServletRequest
public java.lang.String getContextPath()
getContextPath
in interface javax.servlet.http.HttpServletRequest
public javax.servlet.http.Cookie[] getCookies()
getCookies
in interface javax.servlet.http.HttpServletRequest
public long getDateHeader(java.lang.String name)
getDateHeader
in interface javax.servlet.http.HttpServletRequest
name
- Name of the requested date headerjava.lang.IllegalArgumentException
- if the specified header value
cannot be converted to a datepublic java.lang.String getHeader(java.lang.String name)
null
getHeader
in interface javax.servlet.http.HttpServletRequest
name
- Name of the requested headerpublic java.util.Enumeration getHeaders(java.lang.String name)
getHeaders
in interface javax.servlet.http.HttpServletRequest
name
- Name of the requested headerpublic java.util.Enumeration getHeaderNames()
getHeaderNames
in interface javax.servlet.http.HttpServletRequest
public int getIntHeader(java.lang.String name)
getIntHeader
in interface javax.servlet.http.HttpServletRequest
name
- Name of the requested headerjava.lang.IllegalArgumentException
- if the specified header value
cannot be converted to an integerpublic java.lang.String getMethod()
getMethod
in interface javax.servlet.http.HttpServletRequest
public java.util.Map getParameterMap()
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.getParameterMap
in interface javax.servlet.ServletRequest
getParameterMap
in class ServletRequestImpl
Map
containing parameter names as keys
and parameter values as map values.public java.lang.String getPathInfo()
getPathInfo
in interface javax.servlet.http.HttpServletRequest
public java.lang.String getPathTranslated()
getPathTranslated
in interface javax.servlet.http.HttpServletRequest
public java.lang.String getQueryString()
getQueryString
in interface javax.servlet.http.HttpServletRequest
public java.lang.String getRemoteUser()
getRemoteUser
in interface javax.servlet.http.HttpServletRequest
public java.lang.String getRequestedSessionId()
getRequestedSessionId
in interface javax.servlet.http.HttpServletRequest
public java.lang.String getRequestURI()
getRequestURI
in interface javax.servlet.http.HttpServletRequest
public java.lang.StringBuffer getRequestURL()
Because this method returns a StringBuffer
,
not a String
, you can modify the URL easily,
for example, to append query parameters.
This method is useful for creating redirect messages and for reporting errors.
getRequestURL
in interface javax.servlet.http.HttpServletRequest
StringBuffer
object containing the
reconstructed URLpublic java.lang.String getServletPath()
getServletPath
in interface javax.servlet.http.HttpServletRequest
public javax.servlet.http.HttpSession getSession()
getSession
in interface javax.servlet.http.HttpServletRequest
public javax.servlet.http.HttpSession getSession(boolean create)
getSession
in interface javax.servlet.http.HttpServletRequest
create
- Create a new session if one does not existpublic boolean isRequestedSessionIdFromCookie()
true
if the session identifier included in this
request came from a cookie.isRequestedSessionIdFromCookie
in interface javax.servlet.http.HttpServletRequest
public boolean isRequestedSessionIdFromURL()
true
if the session identifier included in this
request came from the request URI.isRequestedSessionIdFromURL
in interface javax.servlet.http.HttpServletRequest
public boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromURL()
instead.true
if the session identifier included in this
request came from the request URI.isRequestedSessionIdFromUrl
in interface javax.servlet.http.HttpServletRequest
public boolean isRequestedSessionIdValid()
true
if the session identifier included in this
request identifies a valid session.isRequestedSessionIdValid
in interface javax.servlet.http.HttpServletRequest
public boolean isUserInRole(java.lang.String role)
true
if the authenticated user principal
possesses the specified role name.isUserInRole
in interface javax.servlet.http.HttpServletRequest
role
- Role name to be validatedpublic java.security.Principal getUserPrincipal()
getUserPrincipal
in interface javax.servlet.http.HttpServletRequest