File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 300
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: 300
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to pass session object in other Action class
 
Similar Threads
Share my WebApp Security implementations
JSF to Struts conversion
How I can access session objects within Form object extended ActionForm class
Session problem
Will tomcat creates a new session for every forward to a jsp page