0

I want to send a String to user Actually I don't have any file for it. It is only a standard java string and I want user to download it rather than see it on browser.

Most of the example on internet are based on a static file which is not useful for my case.

Vahid Hashemi
  • 5,182
  • 10
  • 58
  • 88

1 Answers1

3

austin,i think you need set the response header,following is the code:

getResponse().setHeader("Content-Disposition", "attachment;filename=filename");
getResponse().setDateHeader("Expires", 0);
getResponse().setHeader("Cache-Control" , "no-cache");
getResponse().setHeader("Pragma", "no-cache");

where the getResponse() gets the httpServletResponse.

Leiting
  • 46
  • 2