Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Jazzez Selvan
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.
 
Anirvan Majumdar
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.
 
Steve Adam
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!