Hi,
i have problem when download file with content type"application/octet-stream" in HTTPS,
when use HTTP download file is ok!!
in IE when click actionLink the browser open a popup box with the text "Cannot download file.jsf from host. Can not open the website. Site not available or found. Please try again at a later time"
in Firefox it's OK
My application server is glassfish v2 and action method for download is:
<h:commandLink actionListener="#{PreventivoFindBB.downloadAttached}">
<h:outputText value="#{allegato.name}" styleClass="label"/>
<f:param name="fileId" value="#{allegato.name}"/>
</h:commandLink>
public String downloadAttached(ActionEvent event) {
String sid = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("fileId");
System.out.println("Param: " + sid);
BufferedInputStream input = null;
HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
for (File file : preventivo.getListFile()) {
if (file.getName().equals(sid)) {
try {
input = new BufferedInputStream(new FileInputStream(file));
int contentLength = input.available();
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=" + file.getName());
response.setHeader("Cache-Control", "no-cache");
// Write file contents to response.
while (contentLength-- > 0) {
response.getOutputStream().write(input.read());
}
} catch (Exception ex) {
String msg = "Sorry";
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg));
ex.printStackTrace();
return null;
}
FacesContext faces = FacesContext.getCurrentInstance();
faces.responseComplete();
}
}
return null;
}
Have you any idea?
Edited by: Rosario on Jul 29, 2008 4:30 AM