public final class Servlets extends Object
Modifier and Type | Method and Description |
---|---|
static <T> T |
getApplicationAttribute(javax.servlet.ServletContext context,
String name)
Returns the application scope attribute value associated with the given name.
|
static String |
getForwardRequestQueryString(javax.servlet.http.HttpServletRequest request)
Returns the original HTTP request query string behind this forwarded request, if any.
|
static String |
getForwardRequestURI(javax.servlet.http.HttpServletRequest request)
Returns the original HTTP request URI behind this forwarded request, if any.
|
static String |
getForwardRequestURIWithQueryString(javax.servlet.http.HttpServletRequest request)
Returns the original HTTP request URI with query string behind this forwarded request, if any.
|
static String |
getRequestBaseURL(javax.servlet.http.HttpServletRequest request)
Returns the HTTP request base URL.
|
static String |
getRequestDomainURL(javax.servlet.http.HttpServletRequest request)
Returns the HTTP request domain URL.
|
static String |
getRequestHostname(javax.servlet.http.HttpServletRequest request)
Returns the HTTP request hostname.
|
static Map<String,List<String>> |
getRequestQueryStringMap(javax.servlet.http.HttpServletRequest request)
Returns the HTTP request query string as parameter values map.
|
static String |
getRequestRelativeURI(javax.servlet.http.HttpServletRequest request)
Returns the HTTP request URI relative to the context root of a web application.
|
static String |
getRequestRelativeURIWithoutPathParameters(javax.servlet.http.HttpServletRequest request)
Returns the HTTP request URI relative to the context root of a web application.
|
static String |
getRequestURIWithQueryString(javax.servlet.http.HttpServletRequest request)
Returns the HTTP request URI with query string.
|
static String |
getRequestURLWithQueryString(javax.servlet.http.HttpServletRequest request)
Returns the HTTP request URL with query string.
|
static Map<String,List<String>> |
toParameterMap(String queryString)
Converts the given query string to request parameter values map.
|
public static String getRequestHostname(javax.servlet.http.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(javax.servlet.http.HttpServletRequest request)
request
- The involved HTTP servlet request.HttpServletRequest.getRequestURL()
,
HttpServletRequest.getRequestURI()
public static String getRequestBaseURL(javax.servlet.http.HttpServletRequest request)
<base>
tag.request
- The involved HTTP servlet request.HttpServletRequest.getRequestURL()
,
HttpServletRequest.getRequestURI()
,
HttpServletRequest.getContextPath()
public static String getRequestRelativeURI(javax.servlet.http.HttpServletRequest request)
request
- The involved HTTP servlet request.public static String getRequestRelativeURIWithoutPathParameters(javax.servlet.http.HttpServletRequest request)
request
- The involved HTTP servlet request.public static String getRequestURLWithQueryString(javax.servlet.http.HttpServletRequest request)
request
- The involved HTTP servlet request.HttpServletRequest.getRequestURL()
,
HttpServletRequest.getQueryString()
public static String getRequestURIWithQueryString(javax.servlet.http.HttpServletRequest request)
request
- The involved HTTP servlet request.HttpServletRequest.getRequestURI()
,
HttpServletRequest.getQueryString()
public static Map<String,List<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 String getForwardRequestURI(javax.servlet.http.HttpServletRequest request)
public static String getForwardRequestQueryString(javax.servlet.http.HttpServletRequest request)
public static String getForwardRequestURIWithQueryString(javax.servlet.http.HttpServletRequest request)
public static Map<String,List<String>> toParameterMap(String queryString)
queryString
- The query string.public static <T> T getApplicationAttribute(javax.servlet.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)
Copyright © 2012–2014 OmniFaces. All rights reserved.