Have you tried the OReilly package?
http://www.servlets.com/resources/com.oreilly.servlet/cos.zip
Works good for me, easy:

import com.oreilly.servlet.ServletUtils;

req.setContentType(type);
try {
      ServletUtils.returnFile(yourFile, out);
    }
    catch (FileNotFoundException e) {  }

- Jon

"Jo�o Carlos Costa" wrote:

> I want to be able to allow users to download ANY binary file from a
> web server using servlets. The servlet must operate on either NN and
> IE environments.
> I have tried the following:
>
> res.setContentType("application/x-zip-compressed; name=\"" + itemName+
> '\"');
> res.setHeader("Content-disposition", "attachment; filename=\\"" +
> itemName +'\"\);
> res.setContentLength(getItem().length);
>
> This works fine, if I want to download a zip file. But if I want to
> download a file which is not a zip, how am I supposed to do? I
> developed a servlet (works beautifully), different from Jason
> Hunter's, that uploads ANY binary file using multipart/form-data and I
> simply can't do the same for a download.
>
> Does any of you, Servlet experts, have an example of a servlet that
> downloads ANY binary file? I would appreciate any help from you.
>
> Thanks
> ===
> Joao Carlos Costa
>
> _________________________________________________________
> DO YOU YAHOO!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
> ___________________________________________________________________________
> 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

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Jon Baer / MTV Networks
1515 Broadway - 29th Floor
New York, NY 10036
T. 212-846-5984
F. 212-846-1801
E. [EMAIL PROTECTED]
=-=-=-=-=-=-=-=-=-=-=-=-=-=-

___________________________________________________________________________
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