1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
public String telecharger(ActionEvent event)
{
try {
final HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
byte[] zip = getZipData();
ServletOutputStream sos;
sos = response.getOutputStream();
response.setContentType("application/zip");
response.setHeader("Content-Disposition", "attachment; filename=\"monArchive.zip\"");
sos.write(zip);
sos.flush();
sos.close();
FacesContext.getCurrentInstance().responseComplete();
} catch (Exception e)
{
e.printStackTrace();
log.error("error during the download: "+e);
}
return "maPage";
} |
Partager