wood burning stoves 2.0*
The moose likes Struts and the fly likes  session in Strut2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark " session in Strut2" Watch " session in Strut2" New topic
Author

session in Strut2

pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 300
What is the best of way of defining the session in strut2.

I define the session in my application as .

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

session.put("loginDetails", user);

Is any other best way to define the session in strut2.

Thanks.
Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489

Hi..
I think that's the only one way to use Session in Struts2..
Because i've used it too..

Correct me if i'm wrong..
Thanks in advance..


Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 300

Actually i am facing a problem.When more than one user login in the application .Some time its show the data of other user to other user.

Please tell me where i am wrong.

Thanks
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

You can use SessionAware interface for setting session in your action class. Example...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Implementing SessionAware is the best way to get access to the session, and makes testing easier.

If you're getting session "crosstalk" then it's nearly certain you're doing something wrong; without code (and possibly configs) it's impossible to help.
pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 300
Hi,
When the user login .
I set the session as

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

session.put("loginDetails", user);

And in other action i am getting the user information as



Can any body tell me where i am wrong.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

That code is fine.

What makes you think you're getting session crosstalk? How are you confirming you're having a problem?
pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 300
Hi,
Actually this kind of problem coming from specific location.

And i found that they using proxy server.

Is there any code that the data should be pick from server not from proxy server cache.


Thanks

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: session in Strut2
 
Similar Threads
how to set the request Session in Strut2
Strut2 + doubleselect Tag
Downlaod in Strut2
Include action in strut2
Instead of token is any other way to stop duuplicate frm submssion in strut2.