public class SessionMap<K,V> extends AbstractMap<K,V> 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<K,V>> |
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<K,V>> |
entrySet()
Returns a Set of attributes from the http session.
|
V |
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.
|
V |
put(K key,
V value)
Saves an attribute in the session.
|
V |
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 V get(Object key)
public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
containsKey
in class AbstractMap<K,V>
key
- the name of the session attribute.Copyright © 2000–2020 Apache Software Foundation. All rights reserved.