hai,

I am facing a problem of sending back zip file from my servlet code.


Prob:
====
        In my html page, i have given a link to a servlet page, which
        will in turn send back a zip file.

        if i click on the link, it pops up a dialogue box, saying whether
        i want to open it or save it.

        If i select to save, then it is saving properly and everything is
ok.

        But the main problem is that, when i try to open it directly
        it opens up a blank zip file(eventhough the zip file is not
empty).??

        For pdf files and word documents it is working perfectly.

        I have put the code below, which i am using to send back the files.

        I am using Resin servlet engine and Apache Webserver.

        Expecting a very good solution for this?

have a nice time,

Ashok

=============================================
Code for sending back zip files:
        req is the HttpServletRequest object
        resp is the HttpServletResponse object

                        String sFileName = req.getPathTranslated();

                        String contentType =
getServletContext().getMimeType(sFileName);

                        resp.setContentType( contentType);

                        FileInputStream fis = new
FileInputStream(sFileName);

                        byte[] buf = new byte[500* 1024];

                        int bytesRead;
                        ServletOutputStream out = resp.getOutputStream();
                        while( (bytesRead = fis.read(buf)) != -1 )
                                  {
                                out.write( buf, 0, bytesRead);
                                  }
                          }
                          catch(Exception ex)
                          {
                                  logCat.info( "ashok_exception " +
ex.getMessage());
                          }

                        return;

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to