|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.messagelet.impl.ServletRequestImpl org.apache.commons.messagelet.impl.HttpServletRequestImpl
public class HttpServletRequestImpl
Based on the HttpRequestBase code from Catalina.
Field Summary | |
---|---|
protected String |
authType
The authentication type used for this request. |
protected String |
contextPath
The context path for this request. |
protected ArrayList |
cookies
The set of cookies associated with this Request. |
protected SimpleDateFormat[] |
formats
The set of SimpleDateFormat formats to use in getDateHeader(). |
protected HashMap |
headers
The HTTP headers associated with this Request, keyed by name. |
protected String |
method
The request method associated with this Request. |
protected String |
pathInfo
The path information for this request. |
protected String |
queryString
The query string for this request. |
protected boolean |
requestedSessionCookie
Was the requested session ID received in a cookie? |
protected String |
requestedSessionId
The requested session ID (if any) for this request. |
protected boolean |
requestedSessionURL
Was the requested session ID received in a URL? |
protected String |
requestURI
The request URI associated with this request. |
protected String |
servletPath
The servlet path for this request. |
protected HttpSessionImpl |
session
The currently active session for this request. |
protected Principal |
userPrincipal
The Principal who has been authenticated for this Request. |
Fields inherited from class org.apache.commons.messagelet.impl.ServletRequestImpl |
---|
attributes, authorization, characterEncoding, contentLength, contentType, defaultLocale, input, locales, protocol, reader, remoteAddr, remoteHost, scheme, secure, serverName, serverPort, servletContext, stream |
Fields inherited from interface javax.servlet.http.HttpServletRequest |
---|
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH |
Constructor Summary | |
---|---|
HttpServletRequestImpl(javax.servlet.ServletContext servletContext)
|
Method Summary | |
---|---|
void |
addCookie(javax.servlet.http.Cookie cookie)
Add a Cookie to the set of Cookies associated with this Request. |
void |
addHeader(String name,
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. |
String |
getAuthType()
Return the authentication type used for this Request. |
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(String name)
Return the value of the specified date header, if any; otherwise return -1. |
String |
getHeader(String name)
Return the first value of the specified header, if any; otherwise, return null |
Enumeration |
getHeaderNames()
Return the names of all headers received with this request. |
Enumeration |
getHeaders(String name)
Return all of the values of the specified header, if any; otherwise, return an empty enumeration. |
int |
getIntHeader(String name)
Return the value of the specified header as an integer, or -1 if there is no such header for this request. |
String |
getMethod()
Return the HTTP request method used in this Request. |
Map |
getParameterMap()
Returns a Map of the parameters of this request. |
String |
getPathInfo()
Return the path information associated with this Request. |
String |
getPathTranslated()
Return the extra path information for this request, translated to a real path. |
String |
getQueryString()
Return the query string associated with this request. |
String |
getRemoteUser()
Return the name of the remote user that has been authenticated for this Request. |
String |
getRequestedSessionId()
Return the session identifier included in this request, if any. |
String |
getRequestURI()
Return the request URI for this request. |
StringBuffer |
getRequestURL()
Reconstructs the URL the client used to make the request. |
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. |
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(String role)
Return true if the authenticated user principal
possesses the specified role name. |
void |
setAuthType(String authType)
Set the authentication type used for this request, if any; otherwise set the type to null . |
void |
setContextPath(String path)
Set the context path for this Request. |
void |
setMethod(String method)
Set the HTTP request method used for this Request. |
void |
setPathInfo(String path)
Set the path information for this Request. |
void |
setQueryString(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(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(String uri)
Set the unparsed request URI for this Request. |
void |
setServletPath(String path)
Set the servlet path for this Request. |
void |
setUserPrincipal(Principal principal)
Set the Principal who has been authenticated for this Request. |
Methods inherited from class org.apache.commons.messagelet.impl.ServletRequestImpl |
---|
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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.servlet.ServletRequest |
---|
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocale, getLocales, getParameter, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding |
Field Detail |
---|
protected String authType
protected String contextPath
protected ArrayList cookies
protected SimpleDateFormat[] formats
protected HashMap headers
protected String method
protected String pathInfo
protected String queryString
protected boolean requestedSessionCookie
protected String requestedSessionId
protected boolean requestedSessionURL
protected String requestURI
protected String servletPath
protected HttpSessionImpl session
protected Principal userPrincipal
Constructor Detail |
---|
public HttpServletRequestImpl(javax.servlet.ServletContext servletContext)
Method Detail |
---|
public void addCookie(javax.servlet.http.Cookie cookie)
cookie
- The new cookiepublic void addHeader(String name, String value)
name
- The new header namevalue
- The new header valuepublic void clearCookies()
public void clearHeaders()
public void setAuthType(String authType)
null
. Typical values are "BASIC",
"DIGEST", or "SSL".
authType
- The authentication type usedpublic void setContextPath(String path)
path
- The context pathpublic void setMethod(String method)
method
- The request methodpublic void setPathInfo(String path)
path
- The path informationpublic void setQueryString(String query)
query
- The query stringpublic void setRequestedSessionCookie(boolean flag)
flag
- The new flagpublic void setRequestedSessionId(String id)
id
- The new session idpublic void setRequestedSessionURL(boolean flag)
flag
- The new flagpublic void setRequestURI(String uri)
uri
- The request URIpublic void setServletPath(String path)
path
- The servlet pathpublic void setUserPrincipal(Principal principal)
getRemoteUser()
method.
principal
- The user Principalpublic String getAuthType()
getAuthType
in interface javax.servlet.http.HttpServletRequest
public 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(String name)
getDateHeader
in interface javax.servlet.http.HttpServletRequest
name
- Name of the requested date header
IllegalArgumentException
- if the specified header value
cannot be converted to a datepublic String getHeader(String name)
null
getHeader
in interface javax.servlet.http.HttpServletRequest
name
- Name of the requested headerpublic Enumeration getHeaders(String name)
getHeaders
in interface javax.servlet.http.HttpServletRequest
name
- Name of the requested headerpublic Enumeration getHeaderNames()
getHeaderNames
in interface javax.servlet.http.HttpServletRequest
public int getIntHeader(String name)
getIntHeader
in interface javax.servlet.http.HttpServletRequest
name
- Name of the requested header
IllegalArgumentException
- if the specified header value
cannot be converted to an integerpublic String getMethod()
getMethod
in interface javax.servlet.http.HttpServletRequest
public 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 String getPathInfo()
getPathInfo
in interface javax.servlet.http.HttpServletRequest
public String getPathTranslated()
getPathTranslated
in interface javax.servlet.http.HttpServletRequest
public String getQueryString()
getQueryString
in interface javax.servlet.http.HttpServletRequest
public String getRemoteUser()
getRemoteUser
in interface javax.servlet.http.HttpServletRequest
public String getRequestedSessionId()
getRequestedSessionId
in interface javax.servlet.http.HttpServletRequest
public String getRequestURI()
getRequestURI
in interface javax.servlet.http.HttpServletRequest
public 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 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(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 Principal getUserPrincipal()
getUserPrincipal
in interface javax.servlet.http.HttpServletRequest
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |