org.apache.struts2.portlet

## Class PortletSessionMap

- java.lang.Object
- - java.util.AbstractMap<String,Object>
  - - org.apache.struts2.portlet.PortletSessionMap

- All Implemented Interfaces:
    Map<String,Object>

      public class PortletSessionMap
      extends AbstractMap<String,Object>

  A simple implementation of the `Map` interface to handle a collection of portlet 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.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.util.AbstractMap

      `AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>`

    - ### Nested classes/interfaces inherited from interface java.util.Map

      `Map.Entry<K,V>`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PortletSessionMap(javax.portlet.PortletRequest request)` Creates a new session map given a portlet request.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()`
    `Set<Map.Entry<String,Object>>` | `entrySet()`
    `Object` | `get(Object key)` Returns the session attribute associated with the given key or `null` if it doesn't exist.
    `Object` | `put(String key, Object value)` Saves an attribute in the session.
    `Object` | `remove(Object key)` Removes the specified session attribute.

    - ### Methods inherited from class java.util.AbstractMap

      `clone, containsKey, 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`

- - ### Constructor Detail

    - #### PortletSessionMap

          public PortletSessionMap(javax.portlet.PortletRequest request)

      Creates a new session map given a portlet request.
      Parameters:
        `request` - the portlet request object.

  - ### Method Detail

    - #### entrySet

          public Set<Map.Entry<String,Object>> entrySet()

      Specified by:
        `entrySet` in interface `Map<String,Object>`
      Specified by:
        `entrySet` in class `AbstractMap<String,Object>`
      See Also:
        `Map.entrySet()`

    - #### get

          public Object get(Object key)

      Returns the session attribute associated with the given key or `null` if it doesn't exist.
      Specified by:
        `get` in interface `Map<String,Object>`
      Overrides:
        `get` in class `AbstractMap<String,Object>`
      Parameters:
        `key` - the name of the session attribute.
      Returns:
        the session attribute or `null` if it doesn't exist.

    - #### put

          public Object put(String key,
                            Object value)

      Saves an attribute in the session.
      Specified by:
        `put` in interface `Map<String,Object>`
      Overrides:
        `put` in class `AbstractMap<String,Object>`
      Parameters:
        `key` - the name of the session attribute.
        `value` - the value to set.
      Returns:
        the object that was just set.

    - #### clear

          public void clear()

      Specified by:
        `clear` in interface `Map<String,Object>`
      Overrides:
        `clear` in class `AbstractMap<String,Object>`
      See Also:
        `Map.clear()`

    - #### remove

          public Object remove(Object key)

      Removes the specified session attribute.
      Specified by:
        `remove` in interface `Map<String,Object>`
      Overrides:
        `remove` in class `AbstractMap<String,Object>`
      Parameters:
        `key` - the name of the attribute to remove.
      Returns:
        the value that was removed or `null` if the value was not found (and hence, not removed).

Copyright © 2000–2026 Apache Software Foundation. All rights reserved.