how can i realize when ie7 and ie8 says "to help protect your bla bla"? Because it prevents my servlet to serve a byte array as file for download
when returning a zip file(byte array) for download, ie7 and ie8 preventing download and says "to help protect your bla bla". Then when i am clicking this bar and clicking to "download file". After page reloading, download isn't starting. Because my download only starts when click a link.
There is no problem at firefox. I only must know how is to detect this situation?
let tell you how the system work:
my donload link:
<a href="javascript:" on开发者_如何学运维click="getSelectedCheckBoxes();downloadForm.submit()">downloadr</a>
after clicking this link i am doing some things in ProcessAction then portlet returning to the jsp. In jsp with codes below forwarding to the servlet which is serve the download:
location.href="<%=request.getContextPath()%>/ZipDownloadServlet?cacheKey=blabla"
The problem is that the resource you are trying to download is not idempotent (i.e. it's not a GET but a POST which is supposed to start the download. To resolve this problem for IE I'd suggest to put a redirection in between the POST and the download, so
- the POST prepares the download (possibly checking POSTed parameters, whatnot) and
- then redirects using a HTTP 303 response code with the
Location
header set to an (temporary) URL where the resource can be requested via GET - when IE decides that it wants to ask the user for permission and then GET again, there is no problem because your resource is idempotent and can be downloaded as often as IE likes to try
You have to make sure that you issue an HTTP request for a file download only within a user-initiated event handler, generally a "click" event from the page. (It may in fact be that only click events work; I've not bothered to investigate since there's almost always a "click" involved anyway.)
You cannot prevent the browser from behaving that way.
精彩评论