public final class Servlets extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
getApplicationAttribute(ServletContext context,
String name)
Returns the application scope attribute value associated with the given name.
|
static String |
getRequestBaseURL(HttpServletRequest request)
Returns the HTTP request base URL.
|
static String |
getRequestDomainURL(HttpServletRequest request)
Returns the HTTP request domain URL.
|
static String |
getRequestHostname(HttpServletRequest request)
Returns the HTTP request hostname.
|
static Map<String,List<String>> |
getRequestQueryStringMap(HttpServletRequest request)
Returns the HTTP request query string as parameter values map.
|
static String |
getRequestURIWithQueryString(HttpServletRequest request)
Returns the HTTP request URI with query string.
|
static String |
getRequestURLWithQueryString(HttpServletRequest request)
Returns the HTTP request URL with query string.
|
public static String getRequestHostname(HttpServletRequest request)
ServletRequest.getServerName() as its
outcome can be influenced by proxies.request - The involved HTTP servlet request.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 String getRequestDomainURL(HttpServletRequest request)
request - The involved HTTP servlet request.HttpServletRequest.getRequestURL(),
HttpServletRequest.getRequestURI()public static String getRequestBaseURL(HttpServletRequest request)
<base> tag.request - The involved HTTP servlet request.HttpServletRequest.getRequestURL(),
HttpServletRequest.getRequestURI(),
HttpServletRequest.getContextPath()public static String getRequestURLWithQueryString(HttpServletRequest request)
request - The involved HTTP servlet request.HttpServletRequest.getRequestURL(),
HttpServletRequest.getQueryString()public static String getRequestURIWithQueryString(HttpServletRequest request)
request - The involved HTTP servlet request.HttpServletRequest.getRequestURI(),
HttpServletRequest.getQueryString()public static Map<String,List<String>> getRequestQueryStringMap(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 <T> T getApplicationAttribute(ServletContext context, String name)
context - The servlet context used for looking up the attribute.name - The application scope attribute name.ClassCastException - When T is of wrong type.ServletContext.getAttribute(String)