public class SessionMap extends AbstractMap<String,Object> implements Serializable
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.AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Modifier and Type | Field and Description |
---|---|
protected Set<Map.Entry<String,Object>> |
entries |
protected javax.servlet.http.HttpServletRequest |
request |
protected javax.servlet.http.HttpSession |
session |
Constructor and Description |
---|
SessionMap(javax.servlet.http.HttpServletRequest request)
Creates a new session map given a http servlet request.
|
Modifier and Type | Method and Description |
---|---|
void |
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.
|
Set<Map.Entry<String,Object>> |
entrySet()
Returns a Set of attributes from the http session.
|
Object |
get(Object key)
Returns the session attribute associated with the given key or null if it doesn't exist.
|
void |
invalidate()
Invalidate the http session.
|
Object |
put(String key,
Object value)
Saves an attribute in the session.
|
Object |
remove(Object key)
Removes the specified session attribute.
|
clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, size, toString, values
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
protected javax.servlet.http.HttpSession session
protected javax.servlet.http.HttpServletRequest request
public SessionMap(javax.servlet.http.HttpServletRequest request)
request
- the http servlet request object.public void invalidate()
public void clear()
public Set<Map.Entry<String,Object>> entrySet()
public Object get(Object key)
AbstractMap.get(java.lang.Object)
to ensure the
expected specialized behaviour is performed here (and not the generic ancestor behaviour).public Object remove(Object key)
AbstractMap.remove(java.lang.Object)
to ensure the
expected specialized behaviour is performed here (and not the generic ancestor behaviour).public boolean containsKey(Object key)
AbstractMap.containsKey(java.lang.Object)
to ensure the
expected specialized behaviour is performed here (and not the generic ancestor behaviour).containsKey
in interface Map<String,Object>
containsKey
in class AbstractMap<String,Object>
key
- the name of the session attribute.Copyright © 2000–2023 Apache Software Foundation. All rights reserved.