tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rob Tomlin" <>
Subject File cannot be download with security-constraint...
Date Thu, 31 Jul 2003 13:09:51 GMT

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);

      byte[] buf = new byte[4 * 1024];  // 4K buffer
      int bytesRead;
      while ((bytesRead = != -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.


Rob Tomlin

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message