public class HttpUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
cookieName(String suffix)
Generate a cookie name by prepending the serverid and _ to the suffix.
|
static String |
extractIP(String result) |
static Cookie |
getCookie(HttpServletRequest req,
String suffix)
return the cookie from the request.
|
static String |
getCookieValue(HttpServletRequest req,
String suffix)
Returns a cookie value.
|
static String |
getRemoteAddress(HttpServletRequest req)
Returns the "real" remote address of a HttpServletRequest.
|
static StringBuilder |
getRequestURLContext(HttpServletRequest req) |
static Cookie |
newCookie(String suffix,
String value)
Generate a new Cookie.
|
static Cookie |
newHttpOnlyCookie(String suffix,
String value)
Generate a new HTTP-only Cookie.
|
static void |
setCookieSecurity(Cookie c,
HttpServletRequest req)
Set the security attribute of a cookie.
|
static void |
setNoCache(HttpServletResponse res)
Deprecated.
Use
ServletUtils.setNoCache(HttpServletResponse) instead. |
@Deprecated public static void setNoCache(HttpServletResponse res)
ServletUtils.setNoCache(HttpServletResponse)
instead.res
- the HTTP-responsepublic static String cookieName(String suffix)
suffix
- public static Cookie newCookie(String suffix, String value)
cookieName(String)
.
the Path is set to the servlet context path and the maxAge to -1.
Please be sure to set httpOnly for the cookie via Cookie.setHttpOnly(boolean)
if appropriate, or use newHttpOnlyCookie(String, String)
directly.
suffix
- the suffix of the cookie namevalue
- the cookie valuepublic static Cookie newHttpOnlyCookie(String suffix, String value)
cookieName(String)
.suffix
- the suffix of the cookie namevalue
- the cookie valuepublic static void setCookieSecurity(Cookie c, HttpServletRequest req)
c
- the cookie for which to set the security attribute.req
- the requestpublic static Cookie getCookie(HttpServletRequest req, String suffix)
req
- suffix
- the name part of the cookie that follows the server id.public static String getCookieValue(HttpServletRequest req, String suffix)
req
- suffix
- the name part of the cookie that follows the server id.public static String getRemoteAddress(HttpServletRequest req)
req
- public static StringBuilder getRequestURLContext(HttpServletRequest req)
@enterprise 10.0.39049 Copyright © 2024 FREQUENTIS AG. All Rights Reserved.