Blank page shown instead of Open/Save As dialog box-CSV file download in IE
I am migrating an application hosted earlier on Oracle 9iAS (9.0.3.1 BP1) to OracleAS 10g (10.1.3) with Struts 1.2.9. While the below JSP code worked for the earlier s/w stack when accessed using IE 5.5 SP2 or above, a blank page is displayed with the new s/w stack. What I mean by "worked earlier" is this. A "Open/Save As" dialog box would appear. Trying to "Open" would open a new IE window launching MS Excel and displaying correct data. Trying to "Save As" would display correct filename and extension in the dialog box.
<%@page autoFlush="false" contentType="application/x-filler"%>
<%
try
{
String fileName = "ABC.CSV";
String strData = "A,B,C";
response.setContentLength(strData.length());
response.setHeader("Content-Type","application/octet-stream");
response.setHeader("Content-Disposition","inline;filename="+fileName);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(strData.getBytes(), 0, strData.getBytes().length);
ouputStream.flush();
ouputStream.close();
}
catch(Exception e)
{
}
%>
I tried some changes listed below:
1. Deliberately introduced compilation errors in the JSP code.
2. Changed contentType="application/x-filler" to various MIME types like application/x-download, application/vnd.ms-excel, removing it altogether.
3. Commented out response.setHeader("Content-Type","application/octet-stream") and also tried other MIME types related to CSV/Excel.
4. Changed Content-Disposition from inline to attachment.
Each of the above resulted in an unacceptable behaviour compared with the earlier state:
1. Blank page shown as if nothing was happening even in case of deliberate incorrect JSP syntax.
2. Dialog box did show up with some combinations. But on trying to "Open" or "Save As", the dialog box shows up a second time. Then while trying to "Open", the contents get opened either inline or in MS Excel but with some additional garbage data like source file name.jsp etc. While trying to "Save As" the file name and extension take on the pattern <URL_Pattern>.htm where URL_Pattern would be "DOWNLOAD_ACTION.do".
Some other information:
1. This code works when accessed from desktop local container (Win 2000) but not when deployed on Unix env (HP-UX B.11.11.0109).
2. Latest patchsets are installed for IE.
3. The existing application is designed to work for ONLY IE 5.5 SP2 or above, so I haven't tried with other browsers. I have tried both IE 5.5 SP2 and 6.0 SP1.
Any help in this regard will be highly appreciated.
Thanks a lot for your valuable time..

