Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

File download - file name doesnot appear  RSS feed

 
Midhun Agnihotram
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

We are using a ServletOutputStream to send a file to the user for download. The code is as below. It reads a file off the disk (C:\abc.zip) and streams it to the user for download. The name of the downloaded file should have been abc.zip.






The file name was abc.zip untill we used IE6 SP2. When we upgraded to IE6 SP3, the filename of the file downloaded changed "reportGeneration.zip" (which I think it gets from the action name). I have no clue why this is happening. I have tried hard coding the filename - but it didnt work. I tried changing the contentType too - no use.

Any ideas ?

Thanks,
Midhun

P.S. I know I should upgrade my browser. But this is our firm uses.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't say for sure, but I'm a little concerned by that "sos.flush();" Once you start writing data to the output stream, you can no longer set any headers, so it's possible that's why your filename is getting lost.
 
Rob Spoor
Sheriff
Posts: 21095
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Midhun Agnihotram wrote:"C:\abc.zip"

\ is an escape character in Java Strings. The above is not the String representation of C:\abc.zip, but of C: followed by character \a followed by bc.zip. As it is, \a is not even a valid character so your code shouldn't even compile. So my request is, please PostRealCode.
 
Midhun Agnihotram
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Rob, I am apologize for that piece of code. That filename is actually generated at runtime. To simplify, I had put it that way.

Ernest, that thing worked after I moved sos.flush() after sos.write(data);

Thanks,
Midhun.

 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Midhun Agnihotram wrote:
Ernest, that thing worked after I moved sos.flush() after sos.write(data);



Great! Thanks for letting us know!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!