public class HttpServletRequestWrapper extends ServletRequestWrapper implements HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH| Constructor and Description |
|---|
HttpServletRequestWrapper(HttpServletRequest request)
Creates a new request wrapper
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
authenticate(HttpServletResponse response) |
java.lang.String |
getAuthType()
Returns the auth type, e.g.
|
java.lang.String |
getContextPath()
Returns the part of the URI corresponding to the application's
prefix.
|
Cookie[] |
getCookies()
Returns an array of all cookies sent by the client.
|
long |
getDateHeader(java.lang.String name)
Converts a date header to milliseconds since the epoch.
|
java.lang.String |
getHeader(java.lang.String name)
Returns the first value for a request header.
|
java.util.Enumeration<java.lang.String> |
getHeaderNames()
Returns an enumeration of all headers sent by the client.
|
java.util.Enumeration<java.lang.String> |
getHeaders(java.lang.String name)
Returns all the values for a request header.
|
int |
getIntHeader(java.lang.String name)
Converts a header value to an integer.
|
java.lang.String |
getMethod()
Returns the HTTP method, e.g.
|
Part |
getPart(java.lang.String name) |
java.util.Collection<Part> |
getParts() |
java.lang.String |
getPathInfo()
Returns the URI part after the selected servlet and null if there
is no suffix.
|
java.lang.String |
getPathTranslated()
Returns the physical path name for the path info.
|
java.lang.String |
getQueryString()
Returns the request's query string.
|
java.lang.String |
getRemoteUser()
Returns the remote user if authenticated.
|
java.lang.String |
getRequestedSessionId()
Returns the session id.
|
java.lang.String |
getRequestURI()
Returns the entire request URI
|
java.lang.StringBuffer |
getRequestURL()
Reconstructs the URL the client used for the request.
|
java.lang.String |
getServletPath()
Returns the URI part corresponding to the selected servlet.
|
HttpSession |
getSession()
Returns the current session, creating one if necessary.
|
HttpSession |
getSession(boolean create)
Returns a session.
|
java.security.Principal |
getUserPrincipal()
Returns the equivalent principal object for the authenticated user.
|
boolean |
isRequestedSessionIdFromCookie()
Returns true if the session came from a cookie.
|
boolean |
isRequestedSessionIdFromUrl()
Deprecated.
|
boolean |
isRequestedSessionIdFromURL()
Returns true if the session came URL-encoding.
|
boolean |
isRequestedSessionIdValid()
Returns true if the session is valid.
|
boolean |
isUserInRole(java.lang.String role)
Returns true if the user is in the given role.
|
void |
login(java.lang.String username,
java.lang.String password) |
void |
logout() |
void |
setRequest(ServletRequest request)
Sets the request object for the wrapper.
|
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsyncclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsyncpublic HttpServletRequestWrapper(HttpServletRequest request)
request - the wrapped requestpublic void setRequest(ServletRequest request)
setRequest in class ServletRequestWrapperrequest - the wrapped requestpublic java.lang.String getMethod()
REQUEST_METHODgetMethod in interface HttpServletRequestpublic java.lang.String getRequestURI()
getRequestURI in interface HttpServletRequestpublic java.lang.StringBuffer getRequestURL()
getRequestURL in interface HttpServletRequestpublic java.lang.String getContextPath()
getContextPath() is /myapp for the uri
/myapp/servlet/Hello,
getContextPath in interface HttpServletRequestpublic java.lang.String getServletPath()
SCRIPT_NAME
getServletPath() is /servlet/Hello for the uri
/myapp/servlet/Hello/foo.
getServletPath() is /dir/hello.jsp
for the uri /myapp/dir/hello.jsp/foo,getServletPath in interface HttpServletRequestpublic java.lang.String getPathInfo()
PATH_INFO
getPathInfo() is /foo for
the uri /myapp/servlet/Hello/foo.
getPathInfo() is /hello.jsp for for the uri
/myapp/dir/hello.jsp/foo.
getPathInfo in interface HttpServletRequestpublic java.lang.String getPathTranslated()
PATH_TRANSLATEDgetPathTranslated in interface HttpServletRequestpublic java.lang.String getQueryString()
ServletRequest.getParameter() to decode the form values.
Corresponds to CGI's PATH_TRANSLATEDgetQueryString in interface HttpServletRequestpublic java.lang.String getHeader(java.lang.String name)
HTTP_*
String userAgent = request.getHeader("User-Agent");
getHeader in interface HttpServletRequestname - the header namepublic java.util.Enumeration<java.lang.String> getHeaders(java.lang.String name)
getHeaders in interface HttpServletRequestname - the header namepublic java.util.Enumeration<java.lang.String> getHeaderNames()
getHeaderNames in interface HttpServletRequestpublic int getIntHeader(java.lang.String name)
getIntHeader in interface HttpServletRequestname - the header namepublic long getDateHeader(java.lang.String name)
long mod = request.getDateHeader("If-Modified-Since");
getDateHeader in interface HttpServletRequestname - the header namepublic Cookie[] getCookies()
getCookies in interface HttpServletRequestpublic HttpSession getSession(boolean create)
getSession in interface HttpServletRequestcreate - If true, then create a new session if none exists.public HttpSession getSession()
getSession in interface HttpServletRequestpublic java.lang.String getRequestedSessionId()
getRequestedSessionId in interface HttpServletRequestpublic boolean isRequestedSessionIdValid()
isRequestedSessionIdValid in interface HttpServletRequestpublic boolean isRequestedSessionIdFromCookie()
isRequestedSessionIdFromCookie in interface HttpServletRequestpublic boolean isRequestedSessionIdFromURL()
isRequestedSessionIdFromURL in interface HttpServletRequestpublic java.lang.String getAuthType()
getAuthType in interface HttpServletRequestpublic java.lang.String getRemoteUser()
getRemoteUser in interface HttpServletRequestpublic boolean isUserInRole(java.lang.String role)
isUserInRole in interface HttpServletRequestpublic java.security.Principal getUserPrincipal()
getUserPrincipal in interface HttpServletRequestpublic boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromUrl in interface HttpServletRequestpublic boolean authenticate(HttpServletResponse response) throws java.io.IOException, ServletException
authenticate in interface HttpServletRequestjava.io.IOExceptionServletExceptionpublic Part getPart(java.lang.String name) throws java.io.IOException, ServletException
getPart in interface HttpServletRequestjava.io.IOExceptionServletExceptionpublic java.util.Collection<Part> getParts() throws java.io.IOException, ServletException
getParts in interface HttpServletRequestjava.io.IOExceptionServletExceptionpublic void login(java.lang.String username,
java.lang.String password)
throws ServletException
login in interface HttpServletRequestServletExceptionpublic void logout()
throws ServletException
logout in interface HttpServletRequestServletException