I am having a problem downloading a jpeg file from a tomcat java servlet to Internet 
Explorer 6.0.  I have changed the file extension to "zzz" to force the download 
prompt.     If I restart tomcat(version 4.1.x), the download works fine the first 
time.  The correct filename "video.zzz" appears on the prompt and I can hit save and 
it will prompt me as ti where I want to save the file.   However, after the first time 
I get a download prompt with an incorrect filename (the filename is the http query 
request).  If I select "save",then  it does not prompt for a location to save and I 
immediately get error "Internet explorer was not able to open the requested site".     
Is there something else that needs to be set in the http header?


Here is the piece of the java servlet that is issueing the download:

response.setContentType("APPLICATION/OCTET-STREAM");

response.setHeader("Content-Disposition", 
"Attachment;Filename=\"video"+videoid+".zzz\"");

String size=Integer.toString((int)file.length());

response.setHeader("Content-Length",Integer.toString((int)file.length()));


try {

    out = response.getWriter();

    // transfer the file byte-by-byte to the response object

    File fileToDownload = new File("c:\video.zzz");

    FileInputStream fileInputStream = newFileInputStream(fileToDownload);

    int i;

        while ((i=fileInputStream.read())!=-1)

        {

            out.write(i);

    }

    fileInputStream.close();

    out.close();

}catch(Exception e) // file IO errors

{

e.printStackTrace();

}



Thanks,

Terry

Reply via email to