public class SessionUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
getAttribute(javax.servlet.http.HttpSession session,
java.lang.Class<? extends T> type)
Returns the first attribute in the session of the specified type, or null
if no such object is bound to the session.
|
static <T> T |
getAttribute(javax.servlet.http.HttpSession session,
java.lang.String name,
java.lang.Class<? extends T> type)
Returns the attribute with the specified name, but only if the value is
an instance of the specified type.
|
static java.lang.String |
getGeneratedKey(javax.servlet.http.HttpSession session)
Generates a key, using the key generator stored within the session.
|
static java.lang.String |
getString(javax.servlet.http.HttpSession session,
java.lang.String key)
Returns the value of the session stored String.
|
static java.lang.String |
getString(javax.servlet.http.HttpSession session,
java.lang.String key,
java.lang.String defaultValue)
Returns the value of the session stored String.
|
static void |
invalidateSession(javax.servlet.http.HttpServletRequest request)
Invalidates the session obtained from the request.
|
static java.lang.String |
removeValue(javax.servlet.http.HttpSession session,
java.lang.Object value)
Removes a value from the session (without having to know what key it was
bound with).
|
static boolean |
setAttribute(javax.servlet.http.HttpSession session,
java.lang.String name,
java.lang.Object value)
Sets the attribute with the specified value.
|
public static java.lang.String getGeneratedKey(javax.servlet.http.HttpSession session)
session - The session.public static <T> T getAttribute(javax.servlet.http.HttpSession session,
java.lang.Class<? extends T> type)
session - The HTTP sessiontype - the required attribute type.public static <T> T getAttribute(javax.servlet.http.HttpSession session,
java.lang.String name,
java.lang.Class<? extends T> type)
session - The HTTP sessionname - the name of the attribute.type - the required attribute type.public static boolean setAttribute(javax.servlet.http.HttpSession session,
java.lang.String name,
java.lang.Object value)
session - the HTTP session.name - the name of the attribute.value - the value.public static java.lang.String getString(javax.servlet.http.HttpSession session,
java.lang.String key)
session - The sessionkey - The key, which the string is bound to.public static java.lang.String getString(javax.servlet.http.HttpSession session,
java.lang.String key,
java.lang.String defaultValue)
session - The sessionkey - The key, which the string is bound to.defaultValue - The fallback value to returnpublic static void invalidateSession(javax.servlet.http.HttpServletRequest request)
request - The current request.public static java.lang.String removeValue(javax.servlet.http.HttpSession session,
java.lang.Object value)
session - The HttpSessionvalue - The value to be removedCopyright © Technia AB. All Rights Reserved.