2

I should assign unique JSESSIONID after authentication. The JSESSIONID before authentication and after authentication should always be different.

So, how can I do this using Struts 2?

Roman C
  • 49,761
  • 33
  • 66
  • 176

2 Answers2

1

Unique session id you can get if you get HttpSession object. In Struts2

HttpSession session = ServletActionContext.getRequest().getSession();
System.out.println("Old session ID: "+session.getId());
//do authentication
session = ServletActionContext.getRequest().getSession(true);
System.out.println("New session ID: "+session.getId());
Roman C
  • 49,761
  • 33
  • 66
  • 176
1

You should refer to following

http://nickcoblentz.blogspot.in/2008/09/jsessionid-regeneration-in-struts-2.html

Your class must implement SessionAware for this. There are 4 methods suggested for it .

One of them could be

((SessionMap)this.session).invalidate();
this.session = ActionContext.getContext().getSession();
  • how to maintain session id throughout the application can you please tell me –  Nov 28 '14 at 04:38