WebRequest adapter for an jakarta.servlet.http.HttpServletRequest .
| Modifier and Type | Field and Description |
|---|---|
| private static final String[] | DATE_FORMATS
Date formats as specified in the HTTP RFC. |
| private static final Pattern | ETAG_HEADER_VALUE_PATTERN
Pattern matching ETag multiple field values in headers such as "If-Match", "If-None-Match". |
| private static final TimeZone | |
| private boolean | |
| private static final Set |
| Access | Constructor and Description |
|---|---|
| public | ServletWebRequest(HttpServletRequest
current HTTP request request)Create a new ServletWebRequest instance for the given request. |
| public | ServletWebRequest(HttpServletRequest
current HTTP request request, HttpServletResponse current HTTP response (for automatic last-modified handling) response)Create a new ServletWebRequest instance for the given request/response pair. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public boolean | checkNotModified(long
the last-modified timestamp in
milliseconds that the application determined for the underlying
resource lastModifiedTimestamp)Implements org. Check whether the requested resource has been modified given the supplied last-modified timestamp (as determined by the application). |
| public boolean | checkNotModified(String
the entity tag that the application determined
for the underlying resource. This parameter will be padded
with quotes (") if necessary. etag)Implements org. Check whether the requested resource has been modified given the
supplied |
| public boolean | checkNotModified(String
the entity tag that the application determined
for the underlying resource. This parameter will be padded
with quotes (") if necessary. eTag, long the last-modified timestamp in
milliseconds that the application determined for the underlying
resource lastModifiedTimestamp)Implements org. Check whether the requested resource has been modified given the
supplied |
| private boolean | |
| private boolean | |
| public String | getContextPath()
Implements org. Return the context path for this request (usually the base path that the current web application is mapped to). |
| public String | getDescription(boolean
whether to include client-specific
information such as session id and user name includeClientInfo)Implements org. Get a short description of this request, typically containing request URI and session id. |
| public String | getHeader(String headerName)
Implements org. Return the request header of the given name, or |
| public Iterator | getHeaderNames()
Implements org. Return an Iterator over request header names. |
| public String[] | getHeaderValues(String headerName)
Implements org. Return the request header values for the given header name,
or |
| public HttpMethod | |
| public Locale | getLocale()
Implements org. Return the primary Locale for this request. |
| public Object | getNativeRequest()
Implements org. Return the underlying native request object. |
| public <T> T | getNativeRequest(Class<T>
the desired type of request object requiredType)Implements org. Return the underlying native request object, if available. |
| public Object | getNativeResponse()
Implements org. Return the underlying native response object, if any. |
| public <T> T | getNativeResponse(Class<T>
the desired type of response object requiredType)Implements org. Return the underlying native response object, if available. |
| public String | getParameter(String paramName)
Implements org. Return the request parameter of the given name, or |
| public Map | getParameterMap()
Implements org. Return an immutable Map of the request parameters, with parameter names as map keys and parameter values as map values. |
| public Iterator | getParameterNames()
Implements org. Return an Iterator over request parameter names. |
| public String[] | getParameterValues(String paramName)
Implements org. Return the request parameter values for the given parameter name,
or |
| public String | getRemoteUser()
Implements org. Return the remote user for this request, if any. |
| public Principal | getUserPrincipal()
Implements org. Return the user principal for this request, if any. |
| public boolean | |
| public boolean | isSecure()
Implements org. Return whether this request has been sent over a secure transport mechanism (such as SSL). |
| public boolean | isUserInRole(String role)
Implements org. Determine whether the user is in the given role for this request. |
| private boolean | |
| private String | |
| private long | |
| private long | |
| public String | toString()
Overrides org. Returns a string representation of the object. |
| private void | |
| private void | |
| private boolean | |
| private void | |
| private boolean | |
| private boolean |
| DATE_FORMATS | back to summary |
|---|---|
| private static final String[] DATE_FORMATS Date formats as specified in the HTTP RFC.
| |
| ETAG_HEADER_VALUE_PATTERN | back to summary |
|---|---|
| private static final Pattern ETAG_HEADER_VALUE_PATTERN Pattern matching ETag multiple field values in headers such as "If-Match", "If-None-Match".
| |
| GMT | back to summary |
|---|---|
| private static final TimeZone GMT | |
| notModified | back to summary |
|---|---|
| private boolean notModified | |
| SAFE_METHODS | back to summary |
|---|---|
| private static final Set<String> SAFE_METHODS | |
| ServletWebRequest | back to summary |
|---|---|
| public ServletWebRequest(HttpServletRequest request) Create a new ServletWebRequest instance for the given request.
| |
| ServletWebRequest | back to summary |
|---|---|
| public ServletWebRequest(HttpServletRequest request, HttpServletResponse response) Create a new ServletWebRequest instance for the given request/response pair.
| |
| addCachingResponseHeaders | back to summary |
|---|---|
| private void addCachingResponseHeaders(String eTag, long lastModifiedTimestamp) | |
| checkNotModified | back to summary |
|---|---|
| public boolean checkNotModified(long lastModifiedTimestamp) Implements org. Doc from org. Check whether the requested resource has been modified given the supplied last-modified timestamp (as determined by the application). This will also transparently set the "Last-Modified" response header and HTTP status when applicable. Typical usage:
public String myHandleMethod(WebRequest request, Model model) {
long lastModified = // application-specific calculation
if (request.checkNotModified(lastModified)) {
// shortcut exit - no further processing necessary
return null;
}
// further request processing, actually building content
model.addAttribute(...);
return "myViewName";
}
This method works with conditional GET/HEAD requests, but also with conditional POST/PUT/DELETE requests. Note you can use either
this If the "If-Modified-Since" header is set but cannot be parsed to a date value, this method will ignore the header and proceed with setting the last-modified timestamp on the response.
| |
| checkNotModified | back to summary |
|---|---|
| public boolean checkNotModified(String etag) Implements org. Doc from org. Check whether the requested resource has been modified given the
supplied This will also transparently set the "ETag" response header and HTTP status when applicable. Typical usage:
public String myHandleMethod(WebRequest request, Model model) {
String eTag = // application-specific calculation
if (request.checkNotModified(eTag)) {
// shortcut exit - no further processing necessary
return null;
}
// further request processing, actually building content
model.addAttribute(...);
return "myViewName";
}Note you can use either
this | |
| checkNotModified | back to summary |
|---|---|
| public boolean checkNotModified(String eTag, long lastModifiedTimestamp) Implements org. Doc from org. Check whether the requested resource has been modified given the
supplied This will also transparently set the "ETag" and "Last-Modified" response headers, and HTTP status when applicable. Typical usage:
public String myHandleMethod(WebRequest request, Model model) {
String eTag = // application-specific calculation
long lastModified = // application-specific calculation
if (request.checkNotModified(eTag, lastModified)) {
// shortcut exit - no further processing necessary
return null;
}
// further request processing, actually building content
model.addAttribute(...);
return "myViewName";
}
This method works with conditional GET/HEAD requests, but also with conditional POST/PUT/DELETE requests. Note The HTTP specification recommends
setting both ETag and Last-Modified values, but you can also
use
| |
| eTagStrongMatch | back to summary |
|---|---|
| private boolean eTagStrongMatch(String first, String second) | |
| eTagWeakMatch | back to summary |
|---|---|
| private boolean eTagWeakMatch(String first, String second) | |
| getContextPath | back to summary |
|---|---|
| public String getContextPath() Implements org. Doc from org. Return the context path for this request (usually the base path that the current web application is mapped to).
| |
| getDescription | back to summary |
|---|---|
| public String getDescription(boolean includeClientInfo) Implements org. Doc from org. Get a short description of this request, typically containing request URI and session id. | |
| getHeader | back to summary |
|---|---|
| public String getHeader(String headerName) Implements org. Doc from org. Return the request header of the given name, or Retrieves the first header value in case of a multi-value header. | |
| getHeaderNames | back to summary |
|---|---|
| public Iterator Implements org. Doc from org. Return an Iterator over request header names.
| |
| getHeaderValues | back to summary |
|---|---|
| public String[] getHeaderValues(String headerName) Implements org. Doc from org. Return the request header values for the given header name,
or A single-value header will be exposed as an array with a single element. | |
| getHttpMethod | back to summary |
|---|---|
| public HttpMethod getHttpMethod() Return the HTTP method of the request.
| |
| getLocale | back to summary |
|---|---|
| public Locale getLocale() Implements org. Doc from org. Return the primary Locale for this request.
| |
| getNativeRequest | back to summary |
|---|---|
| public Object getNativeRequest() Implements org. Doc from org. Return the underlying native request object.
| |
| getNativeRequest | back to summary |
|---|---|
| public <T> T getNativeRequest(Class<T> requiredType) Implements org. Doc from org. Return the underlying native request object, if available. | |
| getNativeResponse | back to summary |
|---|---|
| public Object getNativeResponse() Implements org. Doc from org. Return the underlying native response object, if any.
| |
| getNativeResponse | back to summary |
|---|---|
| public <T> T getNativeResponse(Class<T> requiredType) Implements org. Doc from org. Return the underlying native response object, if available. | |
| getParameter | back to summary |
|---|---|
| public String getParameter(String paramName) Implements org. Doc from org. Return the request parameter of the given name, or Retrieves the first parameter value in case of a multi-value parameter. | |
| getParameterMap | back to summary |
|---|---|
| public Map Implements org. Doc from org. Return an immutable Map of the request parameters, with parameter names as map keys and parameter values as map values. The map values will be of type String array. A single-value parameter will be exposed as an array with a single element.
| |
| getParameterNames | back to summary |
|---|---|
| public Iterator Implements org. Doc from org. Return an Iterator over request parameter names.
| |
| getParameterValues | back to summary |
|---|---|
| public String[] getParameterValues(String paramName) Implements org. Doc from org. Return the request parameter values for the given parameter name,
or A single-value parameter will be exposed as an array with a single element. | |
| getRemoteUser | back to summary |
|---|---|
| public String getRemoteUser() Implements org. Doc from org. Return the remote user for this request, if any. | |
| getUserPrincipal | back to summary |
|---|---|
| public Principal getUserPrincipal() Implements org. Doc from org. Return the user principal for this request, if any. | |
| isNotModified | back to summary |
|---|---|
| public boolean isNotModified() | |
| isSecure | back to summary |
|---|---|
| public boolean isSecure() Implements org. Doc from org. Return whether this request has been sent over a secure transport mechanism (such as SSL).
| |
| isUserInRole | back to summary |
|---|---|
| public boolean isUserInRole(String role) Implements org. Doc from org. Determine whether the user is in the given role for this request.
| |
| matchRequestedETags | back to summary |
|---|---|
| private boolean matchRequestedETags(Enumeration<String> requestedETags, String eTag, boolean weakCompare) | |
| padEtagIfNecessary | back to summary |
|---|---|
private String padEtagIfNecessary(String etag)
| |
| parseDateHeader | back to summary |
|---|---|
| private long parseDateHeader(String headerName) | |
| parseDateValue | back to summary |
|---|---|
| private long parseDateValue(String headerValue) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides org. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| updateResponseIdempotent | back to summary |
|---|---|
| private void updateResponseIdempotent(String eTag, long lastModifiedTimestamp) | |
| updateResponseStateChanging | back to summary |
|---|---|
| private void updateResponseStateChanging(String eTag, long lastModifiedTimestamp) | |
| validateIfMatch | back to summary |
|---|---|
| private boolean validateIfMatch(String eTag) | |
| validateIfModifiedSince | back to summary |
|---|---|
| private void validateIfModifiedSince(long lastModifiedTimestamp) | |
| validateIfNoneMatch | back to summary |
|---|---|
| private boolean validateIfNoneMatch(String eTag) | |
| validateIfUnmodifiedSince | back to summary |
|---|---|
| private boolean validateIfUnmodifiedSince(long lastModifiedTimestamp) | |