wood burning stoves 2.0*
The moose likes Servlets and the fly likes application that allows to download a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "application that allows to download a file" Watch "application that allows to download a file" New topic
Author

application that allows to download a file

chets patel
Ranch Hand

Joined: Apr 27, 2010
Posts: 73

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
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Not really an ORM question. I'll move this somewhere more appropriate.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
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?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: application that allows to download a file
 
Similar Threads
How to implement download a file/pdf file in struts.
Unable to dowload the Servlet 2.4 specs.
Junk data in NetScape browser 6.0 when downloading the file
Link to RAD 6.0 help file
pdf file download from a given location struts 2.0