public class PatchedHttpServletRequest extends HttpServletRequestDelegate
delegate
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
Constructor and Description |
---|
PatchedHttpServletRequest(HttpServletRequest delegate,
String contextPath) |
Modifier and Type | Method and Description |
---|---|
String |
getContextPath()
Returns the portion of the request URI that indicates the context
of the request.
|
String |
getRequestURI()
Returns the part of this request's URL from the protocol
name up to the query string in the first line of the HTTP request.
|
StringBuffer |
getRequestURL()
Reconstructs the URL the client used to make the request.
|
getAttribute, getAttributeNames, getAuthType, getCharacterEncoding, getContentLength, getContentType, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getInputStream, getIntHeader, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getMethod, getParameter, getParameterMap, getParameterNames, getParameterValues, getPathInfo, getPathTranslated, getProtocol, getQueryString, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRemoteUser, getRequestDispatcher, getRequestedSessionId, getScheme, getServerName, getServerPort, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isSecure, isUserInRole, removeAttribute, setAttribute, setCharacterEncoding
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
authenticate, getPart, getParts, login, logout
getAsyncContext, getDispatcherType, getServletContext, isAsyncStarted, isAsyncSupported, startAsync, startAsync
public PatchedHttpServletRequest(HttpServletRequest delegate, String contextPath)
public String getContextPath()
HttpServletRequest
It is possible that a servlet container may match a context by
more than one context path. In such cases this method will return the
actual context path used by the request and it may differ from the
path returned by the
ServletContext.getContextPath()
method.
The context path returned by
ServletContext.getContextPath()
should be considered as the prime or preferred context path of the
application.
getContextPath
in interface HttpServletRequest
getContextPath
in class HttpServletRequestDelegate
String
specifying the
portion of the request URI that indicates the context
of the requestServletContext.getContextPath()
public String getRequestURI()
HttpServletRequest
First line of HTTP request | Returned Value | |
---|---|---|
POST /some/path.html HTTP/1.1 | /some/path.html | |
GET http://foo.bar/a.html HTTP/1.0 | /a.html | |
HEAD /xyz?a=b HTTP/1.1 | /xyz |
To reconstruct an URL with a scheme and host, use
HttpUtils.getRequestURL(javax.servlet.http.HttpServletRequest)
.
getRequestURI
in interface HttpServletRequest
getRequestURI
in class HttpServletRequestDelegate
String
containing
the part of the URL from the
protocol name up to the query stringHttpUtils.getRequestURL(javax.servlet.http.HttpServletRequest)
public StringBuffer getRequestURL()
HttpServletRequest
If this request has been forwarded using
RequestDispatcher.forward(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
, the server path in the
reconstructed URL must reflect the path used to obtain the
RequestDispatcher, and not the server path specified by the client.
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 HttpServletRequest
getRequestURL
in class HttpServletRequestDelegate
StringBuffer
object containing
the reconstructed URLCopyright © 2013 JBoss by Red Hat. All Rights Reserved.