0

I am going through some of the links like this SO question and found that a new action context is created for every new Action request.

suppose if there is a request to an Action A, a new ActionContext AC1 is created. I save something like ("xxx","yyy") into the session map, which is in the AC1.

Then there is a request to an Action B by the same user. If a new ActionContext AC2 is created, would it somehow get the session object from the AC1 or would be empty?

Isn't the session object global across multiple requests from same user from same browser?

Community
  • 1
  • 1
vjk
  • 2,163
  • 6
  • 28
  • 42

1 Answers1

0

Yes, the session is "global" for a given user's session (with the caveat that new windows/tabs/etc. may act differently across clients). That's what makes it the session.

An action context may contain anything, including the session. Just because there's a new context per request doesn't mean the data in multiple contexts will all be different.

It doesn't get the session from AC1, it gets it from the session. AC2 doesn't know anything about AC1.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
  • So when a new ActionContext is created struts2 will copy the existing Session into the ActionContext object? And where is the main location for this Session? – vjk Nov 29 '12 at 22:43
  • 1
    @vjk ... The session comes from the HTTP request. – Dave Newton Nov 29 '12 at 22:47