aspose file tools*
The moose likes Struts and the fly likes how to pass session object in other Action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to pass session object in other Action class" Watch "how to pass session object in other Action class" New topic
Author

how to pass session object in other Action class

pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 301
Hi,

I have a action class Login action.

where i have store the use name in the session object.

I want to get the value of this session in other action class.

How it can be done .Please help me.

here is my code of Login action.

addDataToSession(user);


David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

...

It's a map. Get it from the map.Although I'd argue it's cleaner to get the session map via SessionAware, since it'll be easier to write your test cases.

Wishful thinking, perhaps, but the capability is there.
pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 301
Thankx it works.
Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489

sorry i have a little question..

example :

i have Action class :
1.) SuperClass implements SessionAware (which getting a session value)
2.) SubClass1 extends SuperClass
3.) SubClass2 extends SuperClass

is it the both of SubClass1 and SubClass2 can "read" the session value?..

thank's

Sorry my english isn't too good

Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Why not just try it?

In any case, general Java questions should be asked in one of the Java language forums; this one should be in the "Java Beginners" since it's regarding simple inheritance.
 
 
subject: how to pass session object in other Action class