File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes File download box in IE 6.0 opening twice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "File download box in IE 6.0 opening twice" Watch "File download box in IE 6.0 opening twice" New topic

File download box in IE 6.0 opening twice

Adwait Patankar

Joined: Jan 30, 2006
Posts: 6
When we open an excel file thru IE 5.5 from my application
the file download dialog box open once but in IE 6.0 the same dialog box opening twice with a security warning "Some files can harm your computer ....."

After clicking "open" on second attempt it opens the excel file.

Any solution to avoid this ?

my code:

response.setHeader("Content-Disposition", "attachment; filename=\""+runId+".xls\"");
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(byteArrayOutputStream.toByteArray(), 0, byteArrayOutputStream.size());

where byteArrayOutputStream is output after exporting from jasper report.

Thanks in advance
Darren Edwards
Ranch Hand

Joined: Aug 17, 2005
Posts: 69
These are differences in the way the browsers choose to handle file downloads as you don't have direct control over them from the server.

If you want to try and get the same download behaviour in IE you could try changing the first line to

which will prevent IE detecting the file type. It may work, but is a bit of a hack however you look at it
I agree. Here's the link:
subject: File download box in IE 6.0 opening twice
It's not a secret anymore!