This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

save file to client machine  RSS feed

 
Prabhakar Pentela
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,

Can somebody tell me how to save text file on client machine?

Thanks,

Prabhakar P
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Easy way: Provide a link to the text file. They can right-click on it to download the file.

Better way: Provide a servlet that emits the text file after setting the appropriate content-type and content-disposition headers.

In any case, this is not a JSP issue, so I've moved this to the Servlets forum for further discussion.
 
Dale Seng
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will need to pump your text file through the response object. But first, you need to set your response with the right content type. And on the header, set content disposition to an attachement, so that the user will get the download dialog box. But the net of it is that you will get an output stream from the response, and pump the file down that stream, just like any other stream.

--Dale--
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!