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 Passing values across pages for that session/user Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Passing values across pages for that session/user" Watch "Passing values across pages for that session/user" New topic
Author

Passing values across pages for that session/user

Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
Hello All -

I'm developing a web-based app using Struts. My first page is a Category selection screen. I have created Action and ActionForm classes for this page and added entries in struts-config.xml. This part is working fine. The next page will be Parameters selection screen. I still need to create Action and ActionForm classes for this page. One thing I'm not able to find out is how do I pass the values from one page to another ? For instance how does Parameters selection screen will get the value selected in Category selection screen ? I'm thinking of using

* another bean class to store all variables
* using session varibale

But not sure what's the best option. Really appreciate any suggestions.

Thanks much.
Ish Ash
Greenhorn

Joined: Jul 30, 2006
Posts: 3
Why dont you use the same Action form for both screens.

All the form elements that are required in both these screens Category selection screen and Parameters selection screen can be made part of the same ActionForm.

The in the struts-config, define the scope of the bean as "session".

Then when you come to Parameters selection screen, the values selected in the Category selection screen will still be available in the ActionForm.

Let me know if you need more Explaination

--IshAsh
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
You do not have to use session scoped forms to solve this issue if you do not want to. I would probably code this up to use a single form bean that both pages would use. When you submit the first page, the submitted category selected value will be populated on the form and available to the second page. If you need to maintain this value, then store it as a hidden field on the second jsp. Then when the second page is submitted, you will have both the selected category and parameter.

- Brent
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing values across pages for that session/user