public class WebUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
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 String |
encodeCookieValue(String cookieValuePlainText)
Encodes a plain text cookie 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 httpRequest)
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 httpRequest)
Returns the value from the named cookie from the specified request.
|
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) |
static void |
initDebug(javax.servlet.ServletContext servletContext)
Initialize the debug state.
|
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 javax.servlet.http.Cookie |
setCookie(String cookieName,
String value,
javax.servlet.http.HttpServletResponse httpResponse,
javax.servlet.http.HttpServletRequest httpRequest)
Sets a cookie into the response.
|
public static void initDebug(javax.servlet.ServletContext servletContext)
fujion.debug property
value taken from the system properties or, absent that, from the the context parameter
settings in the web.xml file. This method is called during server startup and cannot be
called more than one.servletContext - The servlet context.public static boolean isDebugEnabled()
initDebug(javax.servlet.ServletContext)), the debug
state can affect various application behaviors such as disabling javascript minification.IllegalStateException - Thrown if debug status has not been initialized.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 nullpublic 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 httpRequest)
cookieName - Name of cookiehttpRequest - Request containing cookie.IllegalArgumentException - if arguments are nulldecodeCookieValue(String)public static String getCookieValue(String cookieName, javax.servlet.http.HttpServletRequest httpRequest)
cookieName - Name of cookiehttpRequest - Request containing cookie.IllegalArgumentException - if arguments are nullgetCookie(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 nullURLEncoder.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 nullURLDecoder.decode(String, String),
BaseNCodec.decode(String)public static String getCookieValue(String cookieName)
cookieName - Name of cookieIllegalArgumentException - if argument is null or if underlying HttpServletRequest is
nullgetCookieValue(String, HttpServletRequest)public static javax.servlet.http.Cookie setCookie(String cookieName, String value, javax.servlet.http.HttpServletResponse httpResponse, javax.servlet.http.HttpServletRequest httpRequest)
cookieName - Name of cookie.value - Value of cookie. If null, the cookie is removed from the client if it exists.httpResponse - Response object.httpRequest - Request object.IllegalArgumentException - if cookieName, httpResponse, or httpRequest arguments are
nullpublic static org.springframework.core.io.Resource getResource(String src)
Copyright © 2017 Regenstrief Center for Biomedical Informatics. All rights reserved.