Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Force file download

 
Arun Kumar
Ranch Hand
Posts: 133
Chrome Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Arun the bellow link will help you
Example
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The key is that you need to set the content-disposition response header to "attachment".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic