PDF files work OK for us. It displays right in Explorer (with the plug-in
from Adobe). For files that Explorer does not know how to handle, I put in
the content-disposition fix I got from this list, and that worked great.

Here's the basics of my code...

(The method "writeContent" is basically a loop that gets a byte stream from
the file and writes that directly to the output stream.)

>>>

protected void processRequest(HttpServletRequest request, 
                        HttpServletResponse response)
                        throws ServletException, IOException
{
        FormFile file = (FormFile) request.getAttribute("uploadedFile");
        
        // Set servlet response type -- if not set assume text
        response.setContentType( (file.getContentType() == null) ?
"text/plain" : 
                file.getContentType() );
        // Set the content type so download displays filename instead of
request URI
        response.setHeader("Content-Disposition","attachment; filename=\"" +

                file.getFileName() + "\"");
        
        // Get an output stream
        ServletOutputStream out =  response.getOutputStream();
        
        // output the file
        writeContent( out, file );
}

>>>

Reply via email to