Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

File download Problem

Ranch Hand
Posts: 136
Eclipse IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my application there is an option to export data from a table as a csv file

now when the user submits a page a csv file has to be created and I am streaming the output of the csv to the browser

OutputStream ros = res.getOutputStream();

what mime type should i use inorder to download the file as .csv when i use application/ it tries to save the file as excel

and how do i set the file name of the file to be downloaded now it tries to save the file in the name of the servlet
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any mime extension that the browser doesn't recognize or have an application mapping for will cause it to prompt the user to download the file.
Try text/csv.

The Content-Disposition header allows you to set the name of the file.
You can see an example of its use in this FAQ entry.
Note to self: don't get into a fist fight with a cactus. Command this tiny ad to do it:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic