public class WebUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_ETAG |
static String |
FUJION_VERSION |
| Modifier and Type | Method and Description |
|---|---|
static String |
addETag(javax.servlet.http.HttpServletResponse response,
String etag,
boolean weak)
Add ETag to response.
|
static String |
addQueryString(String url,
String queryString)
Adds the specified query string to the url.
|
static String |
decodeCookieValue(String encodedCookieValue)
Decodes an encoded cookie value
|
static void |
disableCache(javax.servlet.http.HttpServletResponse response)
Add headers to suppress browser caching.
|
static String |
encodeCookieValue(String cookieValuePlainText)
Encodes a plain text cookie value.
|
static String |
formatETag(String etag,
boolean weak)
Formats an ETag into form suitable for storing in a header.
|
static String |
generateETag(String value)
Converts a value to an ETag value.
|
static String |
getBaseUrl()
Returns the base url from the execution context.
|
static javax.servlet.http.Cookie |
getCookie(String cookieName)
Returns the named cookie from the current request.
|
static javax.servlet.http.Cookie |
getCookie(String cookieName,
javax.servlet.http.HttpServletRequest request)
Returns the named cookie from the specified request.
|
static String |
getCookieValue(String cookieName)
Returns the value from the named cookie from the specified request.
|
static String |
getCookieValue(String cookieName,
javax.servlet.http.HttpServletRequest request)
Returns the value from the named cookie from the specified request.
|
static String |
getETag(javax.servlet.http.HttpServletRequest request)
Returns an ETag from an HTTP request.
|
static String |
getETag(javax.servlet.http.HttpServletResponse response)
Returns an ETag from an HTTP response.
|
static String |
getQueryParams()
Returns the query parameter string from the request url.
|
static String |
getRequestUrl()
Returns the original request url from the execution context.
|
static org.springframework.core.io.Resource |
getResource(String src)
Returns the resource corresponding to the source URL.
|
static org.springframework.core.io.Resource |
getResource(String src,
javax.servlet.ServletContext ctx)
Returns the resource corresponding to the source URL.
|
static boolean |
isDebugEnabled()
Returns the debug state of the servlet.
|
static Map<String,String> |
queryStringToMap(String queryString)
Converts the queryString to a map.
|
static Map<String,String> |
queryStringToMap(String queryString,
String valueDelimiter)
Converts the queryString to a map.
|
static String |
randomETag()
Returns a random ETag value.
|
static boolean |
sameETag(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Returns true if the request and response ETags match.
|
static boolean |
sameETag(String requestETag,
String responseETag)
Returns true if the request and response ETags match.
|
static javax.servlet.http.Cookie |
setCookie(String cookieName,
String value,
javax.servlet.http.HttpServletResponse response,
javax.servlet.http.HttpServletRequest request)
Sets a cookie into the response.
|
public static final String FUJION_VERSION
public static final String DEFAULT_ETAG
public static boolean isDebugEnabled()
public static Map<String,String> queryStringToMap(String queryString)
queryString - The query string (leading "?" is optional)public static Map<String,String> queryStringToMap(String queryString, String valueDelimiter)
queryString - The query string (leading "?" is optional)valueDelimiter - String to use to delimit multiple values for a parameter. May be null.public static String addQueryString(String url, String queryString)
url - url to receive the query string.queryString - Query string to add.IllegalArgumentException - if url is null.public static String getQueryParams()
public static String getRequestUrl()
public static String getBaseUrl()
public static javax.servlet.http.Cookie getCookie(String cookieName)
cookieName - Name of cookie.getCookie(String, HttpServletRequest)public static javax.servlet.http.Cookie getCookie(String cookieName, javax.servlet.http.HttpServletRequest request)
cookieName - Name of cookierequest - Request containing cookie.IllegalArgumentException - if any argument is null.decodeCookieValue(String)public static String getCookieValue(String cookieName)
cookieName - Name of cookiegetCookieValue(String, HttpServletRequest)public static String getCookieValue(String cookieName, javax.servlet.http.HttpServletRequest request)
cookieName - Name of cookierequest - Request containing cookie.getCookie(String, HttpServletRequest),
decodeCookieValue(String)public static String encodeCookieValue(String cookieValuePlainText)
Encodes a plain text cookie value.
Note: The direction to use a two-phase encode/decode process (i.e. instead of the Base64 class URL_SAFE option) was intentionalcookieValuePlainText - The plain text to encodeIllegalArgumentException - If the argument is null.URLEncoder.encode(String, String),
Base64.encodeBase64String(byte[])public static String decodeCookieValue(String encodedCookieValue)
Decodes an encoded cookie value
Note: The direction to use a two-phase encode/decode process (i.e. instead of the Base64 class URL_SAFE option) was intentionalencodedCookieValue - The encoded cookie valueIllegalArgumentException - If the argument is null.URLDecoder.decode(String, String),
BaseNCodec.decode(String)public static javax.servlet.http.Cookie setCookie(String cookieName, String value, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServletRequest request)
cookieName - Name of cookie.value - Value of cookie. If null, the cookie is removed from the client if it exists.response - Response object.request - Request object.IllegalArgumentException - if cookieName, response, or request arguments are null.public static org.springframework.core.io.Resource getResource(String src)
src - The URL of the source.public static org.springframework.core.io.Resource getResource(String src, javax.servlet.ServletContext ctx)
src - The URL of the source.ctx - The active servlet context.public static void disableCache(javax.servlet.http.HttpServletResponse response)
response - HTTP response to receive headers.public static String formatETag(String etag, boolean weak)
etag - The ETag to format.weak - If true, mark ETag as weak.public static String addETag(javax.servlet.http.HttpServletResponse response, String etag, boolean weak)
response - HTTP response to receive ETag.etag - ETag to add.weak - If true, mark ETag as weak.public static String getETag(javax.servlet.http.HttpServletRequest request)
request - HTTP request.public static String getETag(javax.servlet.http.HttpServletResponse response)
response - HTTP response.public static boolean sameETag(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
request - The HTTP request.response - The HTTP response.public static boolean sameETag(String requestETag, String responseETag)
requestETag - The request ETag.responseETag - The response ETag.public static String generateETag(String value)
value - Value from which an ETag will be generated.public static String randomETag()
Copyright © 2018 Regenstrief Center for Biomedical Informatics. All rights reserved.