Struts 2 - How to get session in an action class that do not implement SessionAware interface

Sometime, we are not interested to implement SessionAware interface to let Struts 2 framework auto set the session map. Here is how we can get the session map in struts 2 Action class. In your Struts 2 action's execute or some other method, you can get session map like this:
Map sessionMap = ServletActionContext.getContext().getSession();

Comments