File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Force file download Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Force file download" Watch "Force file download" New topic
Author

Force file download

Arun Kumar
Ranch Hand

Joined: Jan 21, 2005
Posts: 129

I have to give the user an option to download a csv file I have created a link which points to this file in the server but when user clicks on the link rather than downloading the file the csv file is displayed in the browser


We are following FrontServlet Architecture hence Streaming the file as the response or response.setHeader is not working

please help
Vinoth Thirunavukarasu
Ranch Hand

Joined: Dec 18, 2008
Posts: 164

Hello Arun the bellow link will help you
Example


Java Best Practices
Linux Best Practices
Amortization Calculator

Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
The key is that you need to set the content-disposition response header to "attachment".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Force file download