Java Mailing List Archive

http://www.gg3721.com/

Home » Struts Users Mailing List »

How to allow to download several files in a zip in Internet Explorer

Ariel

2008-10-13

Replies: Find Java Web Hosting

Author LoginPost Reply
Hi Everybody:
I 'm using struts 1.2 version, in my web application I have a chart where
the user can add several files that are located in the server, then in a
hiperlink the user decide to download the several files in a zip file. I
implemented this functionalities, in Mozilla Firefox works perfectly but
with Internet Explorer doesn't work.
Please could you help to find how to do it correctly to make it works in
both browsers ???
Here I post a piece of my code:
<Code>
        ServletContext    context =
getServlet().getServletContext();
        String         mimetype =
context.getMimeType(filename);
        resp.setContentType( (mimetype != null) ? mimetype
:"multipart/mixed" );
        resp.setHeader( "Content-Disposition", "attachement;
filename=\"chart.zip\"" );
        ZipOutputStream zos = new
ZipOutputStream(resp.getOutputStream());
        ChartStructure chart = (ChartStructure)
req.getSession().getAttribute("chart");
       byte[] buf = new byte[1024];
       int len;
        for (Iterator<Files> iterator = chart.iterator();
iterator.hasNext();){
          Files elem = iterator.next();
          ZipEntry zipEntry = new
ZipEntry(elem.getPhisicalFileName());
          String filepath = elem.getDownloadLink();
          FileInputStream fin = new FileInputStream(path);
          BufferedInputStream in = new BufferedInputStream(fin);
          zos.putNextEntry(zipEntry);
          while ((len = in.read(buf)) >= 0) {
            zos.write(buf, 0, len);
          }
          in.close();
          zos.closeEntry();
       }
        zos.close();
</Code>

I hope you can help me.
Greetings
Ariel
©2008 gg3721.com - Jax Systems, LLC, U.S.A.