public class HttpUtils extends Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_HTTP_PORT |
static int |
DEFAULT_HTTPS_PORT |
static String |
HTTP_SCHEME |
static String |
HTTPS_SCHEME |
Constructor and Description |
---|
HttpUtils() |
Modifier and Type | Method and Description |
---|---|
static StringBuilder |
getBaseRequestUrl(javax.servlet.http.HttpServletRequest request,
boolean forceHttps)
Returns the portion from the URL that includes the scheme, server name and port number, without the server
path.
|
static javax.servlet.http.Cookie |
getCookie(String name,
javax.servlet.http.HttpServletRequest request)
Returns the cookie with the given name for the given request
|
static String |
getCookieValue(String name,
javax.servlet.http.HttpServletRequest request)
Returns the cookie value with the given name for the given request
|
static String |
getFullUrl(javax.servlet.http.HttpServletRequest request,
String relativeUrl)
Returns the full URL for the relative URL based in the specified request.
|
static String |
getRequestUriWithoutContextPath(javax.servlet.http.HttpServletRequest request)
Returns the request URI without the context path.
|
public static final String HTTP_SCHEME
public static final String HTTPS_SCHEME
public static final int DEFAULT_HTTP_PORT
public static final int DEFAULT_HTTPS_PORT
public static StringBuilder getBaseRequestUrl(javax.servlet.http.HttpServletRequest request, boolean forceHttps)
request
- the request object used to build the base URLforceHttps
- if HTTPS should be enforcedpublic static String getFullUrl(javax.servlet.http.HttpServletRequest request, String relativeUrl)
request
- the request object used to build the base URLrelativeUrl
- the relative URLpublic static final String getRequestUriWithoutContextPath(javax.servlet.http.HttpServletRequest request)
request
- the request where to get the URI frompublic static javax.servlet.http.Cookie getCookie(String name, javax.servlet.http.HttpServletRequest request)
name
- the name of the cookierequest
- the request where to extract the request frompublic static String getCookieValue(String name, javax.servlet.http.HttpServletRequest request)
name
- the name of the cookierequest
- the request where to extract the request fromCopyright © 2015 CrafterCMS. All Rights Reserved.