Maciej Tylczy�ski wrote:

> Hello
>
>         I use the scriplet shown below for downloading files.
> When it's text file all is seems to be ok, but zip file is always corrupted.
> I changed contentType ( response.setContentType("application/zip"); ) but it
> didin't help.
>

There are two basic issues here:

* You have to use binary output (i.e. response.getOutputStream()) to
  write a binary file without corruption.  You are tryping to use a
  PrintWriter for this.

* According to the JSP spec, you are not allowed to access the
  binary output stream (or the writer, for that matter) directly.  In
  particular, you will have problems with IllegalStateExceptions
  and extra CR/LF characters.

Therefore, you should set up a servlet to do the binary responses, rather than
trying to do them in a JSP page.

Craig McClanahan

====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to