aspose file tools*
The moose likes Struts and the fly likes display Formfile from struts form in session scope Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "display Formfile from struts form in session scope" Watch "display Formfile from struts form in session scope" New topic
Author

display Formfile from struts form in session scope

Darvesh Niz
Ranch Hand

Joined: May 12, 2008
Posts: 119
Hello all,
i have a struts form with FormFile, it works fine with no issues.
My requirement is when a user selects a file, and click next he is taken to the review stage.
i was wondering can i display the formFile object from Strust action form which is in session
in the review stage.
Once the user reviews he clicks save and then i upload the file nad copy it on to my server.

please let me kwwo
thanks
Darvesh Niz
Ranch Hand

Joined: May 12, 2008
Posts: 119
hello all i hope i made sense

Can anyone please reply if you have any clue.
Basically i dont want to save the Form File to a temp location and show it, since i a users exists in review stage, i have to clean the directory

Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9305
    
  17

I'm not very good at struts 1, but if your FormFile object is in the session, then you can create an action which will call the getInputStream method on the FormFile object and send that stream to the client. The HTML will use the src attribute to point to that action on the <img tag i.e. something like [tt]<img src="getImage.do" /> . The file must be stored temporarily on the server by Struts, so you can generate a direct link to the file too, but I'm not sure how Struts 1 is configured as to where to save the file...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Darvesh Niz
Ranch Hand

Joined: May 12, 2008
Posts: 119
Thanks
That what i am doing right now, when the user selects a file and goes to review state, i store the file in temp location on my server. once the user clicks save, then i move the file from temp location to actual location and deletes teh temp location.

i thought it might be easier if there is a workaround to display the using using the fileForm property in struts, since many times what happens is that a user comes until review stage and then leaves, in this case teh temp folder has the files left there which are obsolete, ofcourse i can go and manually delete teh file.

Any cleaner way to workaround this issue

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: display Formfile from struts form in session scope