Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem while downloading file

 
sreedhar Lackka
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks in advance.
Could any one tell me why we required to put”\” and “;” while downloading any file from web application.
response.setHeader("ContentDisposition","attachment;filename="+fileName+".pdf");

Regards,
Sree
 
Leinad Jan
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

response.setHeader("ContentDisposition","attachment;filename="+fileName+".pdf");

It takes 2 strings as parameters. ; is use as a token in the second string. So it knows that the first command is attachment with it's parameter filename="myFile.pdf". \ is an escape code so in your string, the symbole " will appear in it.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The quotes around the filename are in fact only required when the filename contains spaces.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!