Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

save file to client machine

 
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
 
Marshal
Posts: 67422
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
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--
 
    Bookmark Topic Watch Topic
  • New Topic