Je suis arrivé malheureusement trop tard pour te le dire .
Sinon voici un exemple de modification d'entête dans le cas de téléchargement de fichier :
public ActionForward sendFile( ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception{
ActionErrors errors = new ActionErrors();
ApplicationAccessForm appAccForm = (ApplicationAccessForm)request.getSession().getAttribute("accessBean");
String idReport = (String) request.getParameter("id");
try{
ReportForm reportForm = Report.findById(idReport);
HibernateUtil.closeAndCommitAllSessions();
File file = new File(appAccForm.getApplication().getAppAttachmentAddress()+"/"+reportForm.getReportFile());
FileInputStream fileIn = new FileInputStream(file);
response.setContentType("application/octet");
response.setContentLength((int) file.length());
response.setHeader("Content-disposition","attachment; filename=" + file.getAbsolutePath());
OutputStream respondStream = response.getOutputStream();
byte[] buffer = new byte[262144];
int bytesRead = fileIn.read(buffer);
while (bytesRead >= 0) {
if (bytesRead > 0)
respondStream.write(buffer, 0, bytesRead);
bytesRead = fileIn.read(buffer);
}
respondStream.close();
fileIn.close();
}catch (Exception e) {
e.printStackTrace();
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.dynamic", e.getMessage()));
}
if (!errors.isEmpty()) {
saveErrors(request, errors);
}
return mapping.findForward("reportList");
}
__________________________
La théorie, c'est quand on sait tout et que rien ne fonctionne. La pratique, c'est quand tout fonctionne et que personne ne sait pourquoi. Ici, nous avons réuni théorie et pratique : rien ne fonctionne et personne ne sait pourquoi...