1

Is there any advantages of using SessionMap over Map for a session in web application ?

1 advantage I found was you can invalidate a SessionMap but not Map.

Roman C
  • 49,761
  • 33
  • 66
  • 176
Pratik Shah
  • 1,782
  • 1
  • 15
  • 33

1 Answers1

2

The SessionMap is specifically designed for the purposes if you want to have access to the servlet session attributes. So, the user is able to keep a synchronized collection of objects in session and use it instead of HttpSession directly.

This object is automatically injected by the servletConfig interceptor which is a part of the defaultStack if you implement SessionAware interface in the action class.

As soon as you don't need to work with servlet session directly and don't have access to it you can at least invalidate a session that finalizes the collection of objects in it.

A new session map required to action context if you want to continue to use a session.

Roman C
  • 49,761
  • 33
  • 66
  • 176
  • Hi! I've already read the documentation and some articles on the web, and I always read that sessionMaps store the session attributes. But what attributes are these? – Luciane Dec 20 '13 at 15:59
  • The session map is used to store your attributes, that are stored in the http session as attributes, not in the reverse order. – Roman C Dec 20 '13 at 16:09
  • Are these attributes instances of classes I create on my project? – Luciane Dec 20 '13 at 17:07