• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can set the file name to be download ?  RSS feed

 
Jack Lau
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

Could anyone tell me how can set the file name to be download ?


Thanks in advance!
Jack
 
Priyadharshini Nagarajan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
code as follows

response.setContentType(contentType);
response.setHeader("Content-Disposition", "attachment;filename=".concat(String.valueOf(destFileName)));
ServletOutputStream sos = response.getOutputStream();
ByteArrayOutputStream out1 = new ByteArrayOutputStream();
out1.write(file.getContent());
sos.print(out1.toString());
sos.close();
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!