The moose likes Servlets and the fly likes Force file download Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Force file download" Watch "Force file download" New topic
Author

Force file download

Arun Kumar
Ranch Hand

Joined: Jan 21, 2005
Posts: 127

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".


Code depot of a Java EE / JSF developer | JSF / Eclipse / Tomcat kickoff tutorial | DAO kickoff tutorial | I ♥ Unicode
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Force file download
 
Similar Threads
Export data to csv if the user search exceed 50 results
JSP link to download a file
JSP File Download
Down loading a file using Servlet
Download CSV file from apllication server