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
|
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition",
"attachment;filename=rapport.zip");
URL url = getServlet().getServletContext().getResource(
"rapport.zip");
InputStream in = url.openStream();
ServletOutputStream sot = response.getOutputStream();
byte[] outputByte = new byte[4096];
while (in.read(outputByte, 0, 4096) != -1) {
sot.write(outputByte, 0, 4096);
}
in.close();
sot.flush();
sot.close();
} catch (Exception e) {
e.printStackTrace();
} |
Partager