This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Struts and the fly likes Passing data between pages/requests - Best practice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Passing data between pages/requests - Best practice" Watch "Passing data between pages/requests - Best practice" New topic
Author

Passing data between pages/requests - Best practice

Rick Smith
Greenhorn

Joined: Oct 04, 2004
Posts: 24
I'm trying to write an uplaod feature for my web-app.

I've managed to get the upload part working and am now trying to tidy up the management side of things, i.e. storing the uploaded file to the right location.

Basiacally I have a browse page which allows navigation through a folder/file structure, I present a link on accessable folders to the user to do the upload which navigates them (using a forward action) to the upload page where they choose the file and click 'upload' (MyUploadAction with a form-bean property org.apache.struts.upload.FormFile).

What I want to be able to do is pass the path from the browse page through the upload page to the upload action so it an work out which folder to store the file.

I can imagine two ways of doing this, although they might not be possible, or considered good solutions:

1) Packing.unpacking value into request/response:

The Browse page could somhow set a new request parameter for the path. although I wouldn't have thought the ForwardAction would preserve this value and pass it back out to the upload page? if it did/could do then we may be able to pack it into the form when the upload page is submitted.

- This approach feels a little low-level and would probably require writing javascript or such like in the JSP.

2) A second action:

An Action class could be provided which handles storing the path when the user clicks on upload from the browse page. This would (somhow - session bean) store the path which the MyUploadAction could pick up on when the upload is submitted.

- This approach feels more defined, but would result in more Actions to maintain.


Any guidance on which, if any of these approaches is the recomended route would be appreciate, or any other solution.

Thank you.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Passing data between pages/requests - Best practice