This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes How to pass a session from an Action class to another class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to pass a session from an Action class to another class" Watch "How to pass a session from an Action class to another class" New topic
Author

How to pass a session from an Action class to another class

Mattia Merenda
Ranch Hand

Joined: Dec 14, 2006
Posts: 47
Hi everybody,
I am developing a web application with Struts.
I have a form where the user inserts some values and in Action class I create the query to get the results from a database.
When I submit the form I get a table with these results.
Now I want to make some chart with these results on the table.
I am using Cewolf for this purpose.
To make the chart I must develop a Java class where I need to create the same query that I have in the Action class.
For this reason,I saved all the parameters in the form in a session in my Action class.
Now in the class to make the chart I must call the session that I saved previously.
And for the moment,I am getting errors.So,how to get the session from the Action class in my new class for the charts?
I need a fast answer if it is possible.
Thanks in advance for this.
Mattia
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
I am not 100% sure what you are asking. If you need to get at the session from an Action, you just use the getSession() method of the request passed into the execute method. If you need to get at a form saved on the session, I believe that you need to call request.getSession().getAttribute("FORM") where "FORM" is the name of the form defined in your Action Mapping.

- Brent
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to pass a session from an Action class to another class
 
Similar Threads
Problem with session
DispatchAction problem
Problem with 2 buttons in the same form
How to pass a session from a class to another class
how to create the .rptdesign file using birt api