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 ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Exporting CSV file from Server with Save-As Dialog box.

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I do have a CSV file on the server running which can be referred through http://<hostname>:<ip>/project/<projName>/test.csv. When i click a link on the JSP page it has to pop out with the save as dialog box to export that CSV File on the server. Can anyone suggest me how to do this? Your reply could help me to proceed further. The CSV file was created through BufferedOutputStream using Java on the server end.

Thanks & Regards,
Jazznpselvan.
 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look into the response headers - Content-disposition, Content-type. You should find your answer there.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
entire code for Save As Dialog box need to be written in JSP file
also, the contentType for JSP will be "application/rtf" ... this contentType will make the JSP open as Save As Dialogue box

As mentioned in the above post refer response.addHeader & response.setHeader

use simple out.print statements to write data into csv file

Good Luck !
 
Anirvan Majumdar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Kun All wrote:entire code for Save As Dialog box need to be written in JSP file
also, the contentType for JSP will be "application/rtf" ... this contentType will make the JSP open as Save As Dialogue box...


That's NOT true at all! The implementation doesn't necessarily have to be written in a JSP. A servlet can do the job perfectly, and from a separation-of-concerns perspective, the JSP should NOT include such server side implementations!
As for the content type for a CSV, it is text/csv and text/comma-separated-values
 
    Bookmark Topic Watch Topic
  • New Topic