public class RequestUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static javax.servlet.http.HttpServletRequest |
assertRequest()
Return request, throwing IllegalStateException if invoked outside the scope of an
Execution/ServletRequest
|
static String |
getBaseURL(javax.servlet.http.HttpServletRequest request)
Returns the full base URL for the servlet.
|
static String |
getLocalHostAddress()
Return local host IP.
|
static String |
getRemoteAddress()
Return client's ip address.
|
static javax.servlet.http.HttpServletRequest |
getRequest()
Return current HttpServletRequest.
|
static URL |
getResourceURL(javax.servlet.http.HttpServletRequest request) |
static URL |
getResourceURL(String path) |
static String |
getServerName()
Return server name.
|
static javax.servlet.http.HttpSession |
getSession()
Return current HttpSession
|
static javax.servlet.http.HttpSession |
getSession(javax.servlet.ServletRequest request)
Return current HttpSession given request.
|
static String |
getSessionId()
Get current request's session id or null if session has not yet been created or if invoked
outside the scope of an Execution/ServletRequest.
|
static void |
logHeaderNames()
Logs at trace level the request headers
|
public static javax.servlet.http.HttpServletRequest getRequest()
RequestContextHolder.currentRequestAttributes()public static javax.servlet.http.HttpSession getSession()
public static javax.servlet.http.HttpSession getSession(javax.servlet.ServletRequest request)
request - Servlet request object.public static void logHeaderNames()
public static String getServerName()
ServletRequest.getServerName()public static String getLocalHostAddress()
InetAddress.getHostAddress()public static String getRemoteAddress()
This considers header X-FORWARDED-FOR (i.e. useful if behind a proxy)
public static String getBaseURL(javax.servlet.http.HttpServletRequest request)
request - The servlet request.public static URL getResourceURL(javax.servlet.http.HttpServletRequest request)
public static String getSessionId()
public static javax.servlet.http.HttpServletRequest assertRequest()
IllegalStateException - if called outside scope of an HttpServletRequestCopyright © 2017 Regenstrief Center for Biomedical Informatics. All rights reserved.