I'm uploading (binary) files to a BLOB (most of the time word or pdf). When I try to download a file a came across the following: - After I click on a file to be downloaded (a html:link calling appropriate action) I get this Open/Save dialog. - When I click Open, Word displays a warning that a file could not be found - When I try again, Word opens the file just fine
This is only the case with IE. With Opera it works the first time. But I need it to work in IE.
I've run into the same problem, and in my case, the problem was related to the browser cache. Most of the time, I have code to prevent the browser from caching my pages, so that I'm always sure to get fresh information. However, when downloading it's important that browser caching is enabled. If a user selects "open", Internet Explorer attempts to open the document from the browser cache. If you've instructed the browser not to cache the document, it isn't there to open. Try adding the following to your download action, and see if it fixes the problem:
Well Merrill, it does work indeed. Thanks for your reaction and help.
But,... Could you also explain why did it work without it in Opera? With other words, will this allways work independently of browser settings? Or should I warn the users to set their browsers in a certain way?
To prevent dirty reads as a result of a back button.
Thanks again, Milan
posted 13 years ago
I don't know much about the inner workings of Opera, but I supect that the reason Opera works and IE doesn't is that Opera doesn't rely on the browser cache when a user opts to open a downloaded file while IE does.
You can keep your nocache="true" setting in the struts-config.xml file. By placing the code that I gave you in the action, you are overriding this option just for the one action, while all others continue to instruct the browser not to cache the document. This technique does not rely on the users setting their browsers in any certain way, so you don't need to worry about that.