Hi,

I have a serlvet that is used to download a file to the client.

I am using Tomcat 4.1.24, with IE6.

All is fine when no <security-constraint> is applied in the deployment
descriptor, but when I introduce such a constraint the file cannot be
downloaded. I recieve the error:

Internet Explorer cannot download servlet?d=file.pdf from localhost.

My code to download is:

try {

        String filename = "spec1.pdf";
        String downloadType = "application/pdf";

        response.setContentType(downloadType+"; name=\""+filename+"\"") ;

        File file = new File("/" + filename);
      FileInputStream in = new FileInputStream(file);
      response.setContentLength((int)file.length());

      byte[] buf = new byte[4 * 1024];  // 4K buffer
      int bytesRead;
      while ((bytesRead = in.read(buf)) != -1) {
        out.write(buf, 0, bytesRead);
      }
}
finally {
        if (in != null) in.close();
}

I found some references to setting the content-dispostion header however
setting this did not seem to solve the problem:

response.setHeader("Content-Disposition","inline; filename=\"" + filename + "\";");

Any ideas/solutions would be greatly apprieciated.

Cheers

Rob Tomlin

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to