| Home > FAQs > How do we get access to the session |
You can obtain the session attributes by asking the ActionContext or implementing SessionAware. Implementing SessionAware is preferred.
The session attributes are available on the ActionContext instance, which is made available via ThreadLocal.
Preferred
servletConfig Interceptor is included in the Action's stack.
_ servletConfig_.setSession method. You may wish to include a companion getSession method.getSession to obtain a Map representing the session attributes.@see struts-default.xml
@see org.apache.struts.acton2.interceptor.SessionAware
@see org.apache.struts.acton2.interceptor.Servlet Config Interceptor