wood burning stoves 2.0*
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
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