This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing data between pages/requests - Best practice  RSS feed

Rick Smith
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!