Two Laptop Bag*
The moose likes Servlets and the fly likes File-download naming problem in IE 6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

File-download naming problem in IE 6

Toby Davis
Ranch Hand

Joined: Apr 09, 2002
Posts: 65
I've read other threads related to file download using servlets - however, the solutions offered don't fix a specific problem I'm still having...
Whenever I invoke my file download servlet in IE6 (uisng any file type: txt, pdf, csv, etc), it asks me to open/save the servlet path name, not the name I set in the Content-Disposition header. (In Netscape 4.x, it works perfectly - when invoked, it downloads the file with the name "report.txt" to the client)
Here's my code snippet (basic version):

This should offer to open/save as "report.txt". I thought content-disposition would take care of this filename problem. Is there something simple that I missed?
Thanks
---


SCJP2 (1.4)
Toby Davis
Ranch Hand

Joined: Apr 09, 2002
Posts: 65
So far, in reading many many threads in this forum, and some in other groups outside javaranch, I'm finding that there's no real answer to the Content-Disposition problem in IE.
The consensus is that there was a bug in IE 5, but it was fixed with IE 5.5 Sp2. I'm on IE 6, and I've found no mention as to why this happens.
Anyone have any good insights? It's hard to believe that it's this difficult to write a simple file download servlet...
---
Michael Zalewski
Ranch Hand

Joined: Apr 23, 2002
Posts: 168
It's frustrating. I've encountered the same problem, and sometimes I've fixed it and I'm not really sure why.
How does the URL to download your file look? If it's a GET, try putting a dummy parameter on the end like this ... MyServlet?billgates=Report.txt
Get it? billgates is my 'dummy parameter' <BG>
IE really likes to have URL's that end in the right thing, just like Windows really likes to have MS-word files end in .doc, etc.
Val Pecaoco
Ranch Hand

Joined: Dec 05, 2001
Posts: 156
Hi Toby,
Please see my post in this thread. It worked fine with IE 5.5, so there's no reason it won't with 6.0. But don't forget the other solution I'm proposing
I suggest you do browser sniffing from your servlet so that you can customize the content type and "Content-Disposition" header in both IE and Netscape.
Ex Animo Java!
-- Val


"Knowledge is power, but enthusiasm is the key." -- Lavern Barn
Toby Davis
Ranch Hand

Joined: Apr 09, 2002
Posts: 65
Originally posted by mjzalewski:
If it's a GET, try putting a dummy parameter on the end like this ... MyServlet?billgates=Report.txt

Thanks for the suggestion. Tried this before in a GET, but it simply displays the file on the browser if it's a text file. No prompt for save.
My actual application uses POST, though.
---
Toby Davis
Ranch Hand

Joined: Apr 09, 2002
Posts: 65
Originally posted by Val Pecaoco:
Please see my post in this thread. It worked fine with IE 5.5, so there's no reason it won't with 6.0. But don't forget the other solution I'm proposing

Thanks for the forum link, Val. However, unfortunately, it doesn't work for IE 6. I tried the "application/download" content type, and the removal of "attachment" from Content-Disposition. Same problem.
Has anyone tried this with IE 6?
---
Toby Davis
Ranch Hand

Joined: Apr 09, 2002
Posts: 65
I know I'm talking to myself again but it seems IE 6 is making even the Microsoft VB/ASP communities spout lots of profanity when it comes to file downloads... you should read their discussions when it comes to file downloads in IE6.
I think you can get file download to work in IE6 if you tell your non-tech-saavy users in your company to tweak their browsers by going Internet Options in the Advanced tab and turning on this and turning off that while adding this extension but turning off MIMEs which opens you up to crazy viruses but allows you to download files but sometimes it doesn't do the right filename and so on and so on and so on...
I think you get my point. This frustrated coder just wants to know if a Java servlet file download solution was ever done properly in IE 6!!! End of postings and rants until someone replies. Thanks for not closing your ears.
---
Val Pecaoco
Ranch Hand

Joined: Dec 05, 2001
Posts: 156
Hi again, Toby,
Originally posted by Toby Davis:

However, unfortunately, it doesn't work for IE 6. I tried the "application/download" content type, and the removal of "attachment" from Content-Disposition. Same problem.
Has anyone tried this with IE 6?
---

GRRRRRR
Have they released a patch, yet?!?!?!
Would somebody please flood our desktops with Netscape, Mozilla, or even Opera the next time around?!?!?!
Toby Davis
Ranch Hand

Joined: Apr 09, 2002
Posts: 65
We've had to go with a VB/ASP solution, since my application is running on a Windows box. It's a product called SA FileUp. Messy, having my Java web app call an ASP residing in the IIS space (outside of our app server).
This will get us by for now... but I'll have to tackle this later for a future app that'll be running on a Linux server. The users here are mostly IE 6 and NN6.
Thanks anyway, all.
---
Shanu Paul
Greenhorn

Joined: Aug 19, 2006
Posts: 2
Hi,

Could you please let me know if there is a work around with content-disposition or some other way to provide the file name while downloading a file that works with IE 6? Please let me know. Many thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

Shanu Paul, this thread is over 4 years old. It's be best if you start a new one detailing the problems that you are having.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File-download naming problem in IE 6