• 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

application that allows to download a file

 
Ranch Hand
Posts: 77
Eclipse IDE Tomcat Server Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
I am developing one application that allows me to download a file. i.e. I have one file one my server. I want to provide one link. If a user clicks on that link then he should be able to download the file.
Please help me
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not really an ORM question. I'll move this somewhere more appropriate.
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am developing one application that allows me to download a file. i.e. I have one file one my server. I want to provide one link. If a user clicks on that link then he should be able to download the file.


What type of application are your developing? The only thing that I can infer from your question is that it is a web-based application. What technologies/frameworks are you using?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a sample application in our codebarn that shows how to stream files to a browser from a servlet.

It uses getResourceAsStream which depends on the file being inside the webapp's directory structure.
If your files reside outside the directory structure, you'll want to use a FileReader to read the file instead.

Also look at the Content-Disposition HTTP header. In the example the header uses the "inline" attribute. If you want the user to be presented with a "Save As" dialog box you'll want to change that to "attachment"

In any case, that code should give you a good jump start on writing this yourself.

http://faq.javaranch.com/java/CodeBarnSimpleStream
reply
    Bookmark Topic Watch Topic
  • New Topic