public String download() {
ActionResponseImpl response = (ActionResponseImpl) FacesContext
.getCurrentInstance().getExternalContext().getResponse();
try {
downloadFile(response,"","");
return "";
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// FacesContext.getCurrentInstance().responseComplete();
return null;
}
public void downloadFile(ActionResponseImpl response, String realName,
String fileName) throws IOException {
System.out.println(response.getClass());
response.getRealResponse().setHeader("Content-Disposition",
"attachment; filename=b.rar");
OutputStream output = response.getRealResponse().getOutputStream();
byte[] b = new byte[1024];
int i = 0;
FileInputStream fis = new FileInputStream("c:/upload/upload2/b.rar");
while ((i = fis.read(b)) > 0) {
output.write(b, 0, i);
}
output.flush();
output.close();
}
sorry,i speak english is not very well,so i used google translation to send message to here.my project(jbossportal+jsf) has a problem.it is an download development,i can not download rar or doc file.it will be opened in IE.the problem is "response.getRealResponse().setHeader()" can not do anything.please help me,thank you evenybody