Two Laptop Bag
The moose likes Servlets and the fly likes Problem while downloading file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Problem while downloading file" Watch "Problem while downloading file" New topic
Author

Problem while downloading file

sreedhar Lackka
Ranch Hand

Joined: Jul 05, 2008
Posts: 154
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

Joined: Feb 18, 2009
Posts: 28

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

Joined: Oct 08, 2006
Posts: 2458
The quotes around the filename are in fact only required when the filename contains spaces.


Code depot of a Java EE / JSF developer | JSF / Eclipse / Tomcat kickoff tutorial | DAO kickoff tutorial | I ♥ Unicode
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem while downloading file
 
Similar Threads
File download in struts2
File name in Unicode while downloading
Prompt for location when file is downloading
java.net.UnknownHostException
problem with download dialog box