tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Wingfield <jon.wingfi...@mkodo.com>
Subject Re: File cannot be download with security-constraint...
Date Thu, 31 Jul 2003 13:15:16 GMT
ah the old IE + SSL + cacheing problem ;)

Try adding:

final String userAgent = request.getHeader("user-agent");
if (response.containsHeader("Pragma")
     && userAgent!=null
     && userAgent.toUpperCase().indexOf("MSIE")>-1) {
     response.setHeader("Pragma", "public");
}

Solved it for us.

Jon

Rob Tomlin wrote:

> 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: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message