6

I have some binary files in Tomcat webapp folder, that I wish user to download.

I have following code: Window.open(GWT.getHostPageBaseURL()+result, "_blank", "");

I checked with GWT.log path, and it's correct - it really points to folder with certain file.

Firefox: Downloads every file as expected (either opens image/xml in new tab or prompts save dialog)

Chrome: Seems to be downloading only .zip from what I tried. Others are ignored, nothing happens.

IE8: Opens image/XML in new IE Window. Others are ignored (f.e ZIP blink new window but won't prompt save dialog)

What am I doing wrong? Thanks

Xorty
  • 18,367
  • 27
  • 104
  • 155

5 Answers5

4

I'd suggest using a tool like Fiddler to diagnose this problem by examining the HTTP requests and responses in more detail.

My hunch is it'll turn out to be a mime-type issue, but it's hard to say much for sure without seeing more of what's going on.

Spudley
  • 166,037
  • 39
  • 233
  • 307
2

I recently built something for our organisation more as a cache-buster for use with IE than anything else.

If you could check your output script has the following in it, somewhere at least:-

response.setHeader("Pragma", "public");
response.setHeader("Cache-Control", "max-age=0");
response.setHeader("Content-Disposition", "attachment; filename=\"" + yourfilenamehere + "\"");

Hope this is of some help anyway. The content-disposition thing seemed to be the one that was flaking IE out to be fair, but the caching ones are just practice in my opinion when pulling a file from disk.

Good Luck with your fix!

BizNuge
  • 938
  • 1
  • 8
  • 20
  • I've just tried this in TC6 running on win 7 and it worked across IE8, FF3.6 and Chrome (v?). in all three I was trying a .psd file as I figured this wouldn't be interpreted by the browser properly in any way. .Zip worked across all thre browsers in exactly the same way though. What versions of everything are you running Xorty? – BizNuge Mar 10 '11 at 15:59
  • maybe have a look in your tomcat/conf directory and see if you have the mimetypes listings that come pre-packed with the install. I just checked and the .psd filetype came in as a default mimetype in tomcat/conf/web.xml from at least version 4.1 of tomcat, but before this I'm unsure, so other mimes that you may be trying could well be missing from the config. Sorry to spam the post, but I have to leave work quite soon so wanted to be as concise as possible with what I already know. ;) – BizNuge Mar 10 '11 at 16:09
  • I can't do that now but I'll try it tommorow and report here :) So fart thanks – Xorty Mar 10 '11 at 16:17
  • just tried commenting out the mime type for psd in my web.xml, and the results are still not what you experience. IE pumps out the file as unicode direct into the browser, while chrome and FF seem to beahve perfectly normally, downloading the file. – BizNuge Mar 11 '11 at 08:57
  • Thank you for you effort, but correct answer partially provided Ilia (solved Chrome). As for IE, I just dunno ... not so important ATM. Thanks anyway. – Xorty Mar 11 '11 at 16:18
2

According to this discussion from GWT-group problem with chrome can be that it blocks popups generated by javascript(or callbacks in GWT), but allows to open new window if it's result of user interaction(or button click in GWT).

Ilia Akhmadullin
  • 1,573
  • 1
  • 10
  • 16
0

Just ran into a very similar a case two days ago with IIS. Root cause was an IE setting where automatic prompting for downloading files was disabled. (Firefox worked fine)

Although this was a work around for IE, I have not found a good permanent solution yet. I know it is possible because we have a Tomcat app, that does not have this problem with IE.

jzd
  • 23,473
  • 9
  • 54
  • 76
  • Well the .NET code looks really different then the Wicket code in Tomcat. Same mine-type, same file type, but different browser results, so there is something different happening. If I find more than a work around I will update this answer. – jzd Jan 28 '11 at 14:04
0

Is the server running SSL?

IE has some bizarre restrictions on downloading content that it hands off to third-party apps (zip, pdf, doc, xls, etc). We have resorted to using a combination of excluding specific no-cache headers on our responses and unchecking the "Do not save encrypted pages to disk" in IE. Microsoft is under the impression that this is a "feature". Here are some relevant links discussing the issue:

Microsoft KB: 323308 and 815313

stackoverflow: 1262147

Windows Live: Blog

Atlassian: Jira issue

Community
  • 1
  • 1
jt.
  • 7,625
  • 4
  • 27
  • 24