Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

download file code fails in IE8 but works in IE9

I am trying to create a xls file through java code and allow user to doownload it. The download code is in JSP and it works well in IE9 and other browsers. But it give error in IE 8 as "Unable to dowload file. Unable to open this internet site.The requested site is either unavailable or can not be found.Please try later."

my JSP code is as follows.

    <%@ page import="org.apache.poi.ss.usermodel.Workbook"%><%@ page import="java.io.*"%>
    <%response.setHeader("Pragma","no-cache");
    response.setHeader("Content-disposition", "attachment;filename=DataTemplate.xls");
    response.setContentType("application/vnd.ms-excel");
    OutputStream os = response.getOutputStream(); 
    ((Workbook)request.getAttribute("result")).write(os); os.flush();os.close();%>

I checked all the settings for IE as suggested by microsoft sites. Suggestions from other users on internet are to re-install IE8 but it does not sound good to me as I am getting this issue on multiple machines.

Any help is welcome.

Thanks.

like image 704
Coder Avatar asked Mar 24 '23 06:03

Coder


1 Answers

This issue occurs if the server sends a "Cache-control:no-store" header or sends a "Cache-control:no-cache" header.

One of the solution is to add Cache-Control: private to response header.

Also, There are few official blog on Microsoft Support. Check these links one of them should help you to solve the problem.

http://support.microsoft.com/kb/815313

http://support.microsoft.com/kb/323308

like image 87
Hardik Mishra Avatar answered Apr 07 '23 13:04

Hardik Mishra