//HttpResponse res passed into the method that uses this code

                ServletOutputStream out = res.getOutputStream();
                String contentType = getServletContext().getMimeType (filepath);
                res.setContentType(contentType);
                try {
                        returnFile (filepath, out);
                }

                catch (Exception e){
                        e.printStackTrace();
                        out.println (e.getMessage());
                }
                finally {
                        if (out != null) {out.close();}
                }

        /**returnFile() from p.93 of Jason Hunter's book; highly recommended*/
        public static void returnFile (String filename, OutputStream out) throws 
FileNotFoundException,
IOException {......}


Joan Friedman


>
> Hi
> How to download a file from server to the client using a servlet. (Like
> Upload Servelet example.)
> TIA
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.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

___________________________________________________________________________
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