tags:

views:

156

answers:

3

I need to write a download servlet in java to download a file from the web server. I am setting the response parameters as follows:

resp.setContentType( (mimetype != null) ? mimetype : "application/octet-stream");
resp.setContentLength( (int)f.length() );
resp.setHeader( "Content-Disposition",
                "attachment; filename=\"" + filename + "\"" );

The code seems to work fine with firefox, chrome and IE7 but with IE6 its adding "[1]" in the middle of the filename. E.g. test[1]_check.txt (instead of test_check.txt). There are no duplicate copies of the file on client side and I'm unable to understand where I'm going wrong. Is there an issue with my response parameters?

Thanks in advance

A: 

check the Temp folder:

C:\Documents and Settings\YourUserName\Local Settings\Temp

maybe there's a copy of the file from previous downloads

Boris Pavlović
A: 

I don't think the problem is in setHeader(). What about the code determining the value of filename? Maybe the value is concatenated?

Arne Burmeister
+1  A: 

I think i understand the problem...In creating the filename of the file to be downloaded it is a concatenation of 2 strings such as : test.pdf_check.txt.

Firefox and Chrome download using the same name but IE6 inserts [1] just before the first extension it encounters (.pdf) so I get test[1].pdf_check.txt.

I removed the first extension and it seems to be working fine.

Fell