Search code examples
javajspservletsstruts2actioncontext

Most standard way to implement sessions in strtuts2


I was looking for ways of implementing sessions in struts2. I found

1) Just use getSession() on apache

Map session = ActionContext.getContext().getSession();

2) Using SessionAware on javapoint
Instead of plain map, it uses SessionMap which is a part of struts2 and SessionAware which is too. Only thing that I dont get in tutorial, it uses SessionMap for one class and HttpSession for other class.


So the question is what is the most elegant way of using sessions with struts2 framework?

Edit: @Romann C, your answer, answers how to handle sessionMap, but I want to know which method suits most to me.

Anyone who has downvoted just now should at least leave a comment...


Solution

  • Use Map session = ActionContext.getContext().getSession(); with Struts2