title: Download zip file from httpresponse not working
body: <p>I want to be able to download a zip file from a web page through a Java servlet.</p>
  <p>This code works, i can download a zip file and open it with winrar. But if i try to open it with 7zip it says <code>Cannot open file: it does not appear to be valid archive</code></p>
  <p>Here is the code :</p>
  <pre><code>FacesContext fc = FacesContext.getCurrentInstance();
  HttpServletResponse response = (HttpServletResponse) fc.getExternalContext().getResponse();
  response.setHeader(&quot;Content-Disposition&quot;, &quot;attachment; filename=&quot;+&quot;test.zip&quot;);
  response.setContentType(&quot;application/zip&quot;);
  response.setContentLength(briefcaseService.getContentLength(item, sessionView.getLogAsUser()));
  OutputStream ouputStream;
  try {
              ouputStream = response.getOutputStream();
              briefcaseService.loadReportContentFromReportInstance(item, ouputStream, reportName, sessionView.getLogAsUser());
              fc.responseComplete();
  } catch (Exception e) {
              e.printStackTrace();
  }
  </code></pre>
  <p>Does the problem come from this part of the code or it can come from the <code>loadReportContnetFromReportInstance</code> method?</p>
  <p>If you need any information feel free to ask. Thanks</p>
  <p>EDIT : Here is the method loadReportContentFromReportInstance().</p>
  <pre><code>ByteArrayOutputStream bos = new ByteArrayOutputStream();
  ZipOutputStream zipOut = new ZipOutputStream(bos);
  
  
  // Récupération du document attaché au report
  OxwayDocument docWithAttachement = reportManager.findReportAttachementFromReportInstance(reportInstance, user, reportDef);
  
  if (docWithAttachement.equals(null) || docWithAttachement.getAttachFile().equals(null)) {
      return;
  }
  
  ZipEntry zipEntryReport = new ZipEntry(fileName);
  zipOut.putNextEntry(zipEntryReport);
  zipOut.write(Base64.decode(docWithAttachement.getAttachFile().getBytes()));
  
  zipOut.close();
  bos.close();
  outputStream.write(Base64.decode(docWithAttachement.getAttachFile().getBytes()));
  
  final PrintStream ps = new PrintStream(outputStream, true, &quot;UTF-8&quot;);
  
  ps.flush();
  ps.write(bos.toByteArray());
  
  ps.flush();
  </code></pre>