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 28 29 30 31 32 33 34 35 36
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
response.addHeader("Cache-Control", "post-check=0, pre-check=0");
response.setHeader("Pragma", "no-cache");
response.setHeader("Expires", "Sun, 10 Jan 1998 11:00:00 GMT");
response.setDateHeader("Max-Age", 0);
ServletOutputStream out = response.getOutputStream();
try{
String archivePath = "/archives/fichier_archive.zip";
File archiveFile = new File(archivePath);
byte[] arBytes = new byte[(int)archiveFile.length()];
FileInputStream is = new FileInputStream(archiveFile);
is.read(arBytes);
response.setContentType("application/zip");
response.setHeader("Content-Disposition", "attachment; filename=\"fichier_archive.zip\"");
out.write(arBytes);
}
}catch(Exception e)
{
// TODO:
}
finally{
out.flush();
out.close();
}
} |
Partager