2 Replies Latest reply on Sep 24, 2009 11:45 AM by Nikolay Elenkov

    Problem with the download of large files

    kA kA Newbie


      I have a problem with the download of large files (filesize greater than heap
      space) when using Seam. Without Seam everything works fine. The problem does
      only occur when using the Seam Filter! So I hope anybody can help me with
      this problem.

      In order to reproduce the error, I tried it with the excel example from the
      Seam examples and only adepted the home.xhtml by adding:

      <s:link value="Download" action="#{seamdownload.download()}"/>

      The corresponding bean class:

      public class SeamDownload {
           Log log;
           public void download() {
                try {
                     FacesContext facesContext = FacesContext.getCurrentInstance();
                     HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
                     //File must be greater than the heap space - otherwise it works fine!
                     FileInputStream fis = new FileInputStream("/home/bhellmann/mup/filestorage/BigFileUpload/largefile.tar");
                     response.setHeader("Content-Disposition", "attachment;filename=\""     + "largefile.tar" + "\"");
                       ServletOutputStream out = response.getOutputStream();
                     int length = 0;
                     int filesize = 0;
                     byte[] b = new byte[2048];
                     while((length = fis.read(b)) > 0) {
                          out.write(b, 0, length);
                          filesize += length;
                } catch (Exception e) {

      Is there any solution for this problem? or any ideas?

      Thanks in advance