file downloading error with IE7
Hi,
I'm trying to execute the function in my backing bean
ByteArrayOutputStream stream = new ByteArrayOutputStream();
createExcelFile(stream);
HttpServletResponse response = (HttpServletResponse) faces
.getExternalContext().getResponse();
response.setContentType("application/vnd.ms-excel");
response.setContentLength(stream.size());
response.setHeader("Content-disposition",
"inline; filename=\"Timesheet.xsl\"");
try {
ServletOutputStream out;
out = response.getOutputStream();
out.write(stream.toByteArray());
faces.responseComplete();
} catch (IOException e) {
e.printStackTrace();
}
Everything is great when I save the file, but when I open it in IE7 directly I can see all the xls content but I have error message in my Tomcat console window:
javax.servlet.jsp.JspException: Cannot find FacesContext
at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:427)
at com.sun.faces.taglib.jsf_core.ViewTag.doStartTag(ViewTag.java:125)
..................................
The problem is the following:
Request:
POST /Portal/index.jsf HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: http://localhost:88/Portal/index.jsf?as=timesheetList
Accept-Language: en-us
Content-Type: application/x-www-form-urlencoded
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
Host: localhost:88
Content-Length: 235
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: JSESSIONID=4349FF698370ACC8C69A20545A4ECDED
com.sun.faces.VIEW=_id46%3A_id47&TimesheetTemplate%3ATimesheetTemplateForm=TimesheetTemplate%3ATimesheetTemplateForm&TimesheetTemplate%3ATimesheetTemplateForm%3A_idcl=TimesheetTemplate%3ATimesheetTemplateForm%3A_id3%3A0%3A_id11&as=nullOPTIONS /Portal/ HTTP/1.1
User-Agent: Microsoft Office Protocol Discovery
Host: localhost:88
Content-Length: 0
Connection: Keep-Alive
After that I can download the file - it's ok.
When xls file is opened in IE7 window I see the expected xls content but
IE7 sends two additional requests and they
cause the error message:
Cannot find FacesContext - which is true because nothing is availabe. Is any way to exclude HTTP OPTIONS form jsf?
)
OPTIONS /Portal/ HTTP/1.1
User-Agent: Microsoft Office Protocol Discovery
Host: localhost:88
Content-Length: 0
Connection: Keep-Alive
OPTIONS /Portal/ HTTP/1.1
User-Agent: Microsoft Office Protocol Discovery
Host: localhost:88
Content-Length: 0
Connection: Keep-Alive

