javastruts2actionvaluestackactioncontext

Struts2 Session Storage Location and Management


I was reading Struts2 In Action, and it says for each request an ActionContext, a ValueStack and an Action instance are created, so they are thread safe. I was wondering how does the framework manages session, because it can't be stored in these locations, where does the actual Map gets stored, and how concurrent access to that Map is managed by the framework?


Solution

  • The http session is stored in the SessionMap which is among the other context maps is stored in the action context by the dispatcher when serving a request. The session map is a wrapper for http session object and operations such as get/put are synchronized using a http session object monitor. It simply synchronizes the access to http session attributes, however providing a Map implementation.