4 Replies Latest reply: Jun 8, 2014 9:10 PM by Pgleghorn-Oracle RSS

    set http header / Content Type for file download

    Ghazi Hakim

      Hello,

       

      I need to allow end users of my site to download excel/csv files from the server,

      the classic method is set header of the response in a jsp :

       

      index.jsp

       

      <a href="download.jsp">download the file</a>


      download.jsp :

       

      <%  
       
      String filename = "file.xls";  
       
      String filepath = "C:\\Files\\";  
        response
      .setContentType("APPLICATION/OCTET-STREAM");  
        response
      .setHeader("Content-Disposition","attachment; filename=\"" + filename + "\"");  

        java
      .io.FileInputStream fileInputStream=new java.io.FileInputStream(filepath + filename); 

       
      int i;  
       
      while ((i=fileInputStream.read()) != -1) { 
        out
      .write(i);  
       
      }  
        fileInputStream
      .close();  
      %>

       

      but it's not working with 2 Pages Template with Fatwire 7.6.2,

      Is that because I am not allowed to use "response" in Fatwire ?

       

      Regards,

      Ghazi.