Package org.apache.struts2.dispatcher
Class SessionMap
- All Implemented Interfaces:
Serializable
,Map<String,
Object>
A simple implementation of the
Map
interface to handle a collection of HTTP session
attributes. The entrySet()
method enumerates over all session attributes and creates a Set of entries.
Note, this will occur lazily - only when the entry set is asked for.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Field Summary
-
Constructor Summary
ConstructorDescriptionSessionMap
(jakarta.servlet.http.HttpServletRequest request) Creates a new session map given a http servlet request. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all attributes from the session as well as clears entries in this map.boolean
containsKey
(Object key) Checks if the specified session attribute with the given key exists.entrySet()
Returns a Set of attributes from the http session.Returns the session attribute associated with the given key or null if it doesn't exist.void
Invalidate the http session.Saves an attribute in the session.Removes the specified session attribute.Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, size, toString, values
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
session
protected jakarta.servlet.http.HttpSession session -
entries
-
request
protected jakarta.servlet.http.HttpServletRequest request
-
-
Constructor Details
-
SessionMap
public SessionMap(jakarta.servlet.http.HttpServletRequest request) Creates a new session map given a http servlet request. Note, the enumeration of request attributes will occur when the map entries are asked for.- Parameters:
request
- the http servlet request object.
-
-
Method Details
-
invalidate
public void invalidate()Invalidate the http session. -
clear
public void clear()Removes all attributes from the session as well as clears entries in this map. -
entrySet
Returns a Set of attributes from the http session. -
get
Returns the session attribute associated with the given key or null if it doesn't exist. Note: Must use the same signature asAbstractMap.get(java.lang.Object)
to ensure the expected specialized behaviour is performed here (and not the generic ancestor behaviour). -
put
Saves an attribute in the session. -
remove
Removes the specified session attribute. Note: Must use the same signature asAbstractMap.remove(java.lang.Object)
to ensure the expected specialized behaviour is performed here (and not the generic ancestor behaviour). -
containsKey
Checks if the specified session attribute with the given key exists. Note: Must use the same signature asAbstractMap.containsKey(java.lang.Object)
to ensure the expected specialized behaviour is performed here (and not the generic ancestor behaviour).- Specified by:
containsKey
in interfaceMap<String,
Object> - Overrides:
containsKey
in classAbstractMap<String,
Object> - Parameters:
key
- the name of the session attribute.- Returns:
- true if the session attribute exits or false if it doesn't exist.
-