The SessionAware interface in struts 2.x, our Action class needs to implement the SessionAware interface in order to get the HTTP session behavior in our Action class.
If we implement the SessionAware interface, we need to override the setSession () method of SessionAware in our action class. If we implement our action class from the SessionAware interface, then the struts 2 controller does not enter the exact session object, but it does enter the Map object with the same behavior.
Map m;
public void setSession(Map m)
{
this.m=m;
}
public String execute()
{
m.put("user", "USERNAME");
return SUCCESS;
}
source
share