• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using Struts to save files

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am writing a file manager software using struts. I have written the code to upload the file easily using the html:file tag.
However when the user has to see the files that have been uploaded, I need to give him the ability to save the uploaded file (name displayed as a link) to disk.
How do i do that.
Thanks Karthik
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Karthik,

First of all, I have to ask you to change your display name to comply with our naming policy -- we require people to use real, or at least real-looking names.

Thanks.

As to your question about downloading the files, the general approach is to have a Servlet (Struts Action class in your case) proxy the filesystem for the client. For example, if your upload stores the uploaded files under "/var/data", you'd want your DownloadAction to serve a request to, say "DownloadAction.do?file=sample.txt", by streaming the file "/var/data/sample.txt" to the web browser.
 
Karthik Krishnamurthy
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
Will try that
 
Ranch Hand
Posts: 427
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Karthik,

I wrote a Struts application that demonstrates File Upload and File Download:

http://strutsblobapp.sourceforge.net/

Cheers,

-Sean
 
author
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There seems to be a lot of questions about file upload/download.

Have a look at Struts Recipes, recipe 2.9

Chapter 2 is available at http://www.manning-source.com/books/franciscus/franciscus_chp2.pdf
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kartik,

I went through the code of your applicationa and i have a doubt. In the "fileList.jsp", there is this logic:iterate tag:

<logic:iterate id="file" name="files">

What does this "files" refer to? there is no such field in the form associated with this JSP. Please clarify the same.

Regards,

Vicky
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic