public final class Servlets
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
getApplicationAttribute(javax.servlet.ServletContext context,
java.lang.String name)
Returns the application scope attribute value associated with the given name.
|
static java.lang.String |
getRequestBaseURL(javax.servlet.http.HttpServletRequest request)
Returns the HTTP request base URL.
|
static java.lang.String |
getRequestDomainURL(javax.servlet.http.HttpServletRequest request)
Returns the HTTP request domain URL.
|
static java.lang.String |
getRequestHostname(javax.servlet.http.HttpServletRequest request)
Returns the HTTP request hostname.
|
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getRequestQueryStringMap(javax.servlet.http.HttpServletRequest request)
Returns the HTTP request query string as parameter values map.
|
static java.lang.String |
getRequestURIWithQueryString(javax.servlet.http.HttpServletRequest request)
Returns the HTTP request URI with query string.
|
static java.lang.String |
getRequestURLWithQueryString(javax.servlet.http.HttpServletRequest request)
Returns the HTTP request URL with query string.
|
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
toParameterMap(java.lang.String queryString)
Converts the given query string to request parameter values map.
|
public static java.lang.String getRequestHostname(javax.servlet.http.HttpServletRequest request)
ServletRequest.getServerName() as its
outcome can be influenced by proxies.request - The involved HTTP servlet request.java.lang.IllegalArgumentException - When the URL is malformed. This is however unexpected as the request would
otherwise not have hit the server at all.HttpServletRequest.getRequestURL()public static java.lang.String getRequestDomainURL(javax.servlet.http.HttpServletRequest request)
request - The involved HTTP servlet request.HttpServletRequest.getRequestURL(),
HttpServletRequest.getRequestURI()public static java.lang.String getRequestBaseURL(javax.servlet.http.HttpServletRequest request)
<base> tag.request - The involved HTTP servlet request.HttpServletRequest.getRequestURL(),
HttpServletRequest.getRequestURI(),
HttpServletRequest.getContextPath()public static java.lang.String getRequestURLWithQueryString(javax.servlet.http.HttpServletRequest request)
request - The involved HTTP servlet request.HttpServletRequest.getRequestURL(),
HttpServletRequest.getQueryString()public static java.lang.String getRequestURIWithQueryString(javax.servlet.http.HttpServletRequest request)
request - The involved HTTP servlet request.HttpServletRequest.getRequestURI(),
HttpServletRequest.getQueryString()public static java.util.Map<java.lang.String,java.util.List<java.lang.String>> getRequestQueryStringMap(javax.servlet.http.HttpServletRequest request)
ServletRequest.getParameterMap(), which contains both
the request URL (GET) parameters and and the request body (POST) parameters.
The map entries are in the same order as they appear in the query string.request - The request for which the base URL is computed.public static java.util.Map<java.lang.String,java.util.List<java.lang.String>> toParameterMap(java.lang.String queryString)
queryString - The query string.public static <T> T getApplicationAttribute(javax.servlet.ServletContext context,
java.lang.String name)
context - The servlet context used for looking up the attribute.name - The application scope attribute name.java.lang.ClassCastException - When T is of wrong type.ServletContext.getAttribute(String)