Re: File cannot be download with security-constraint...

2003-07-31 Thread Jon Wingfield
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





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


RE: File cannot be download with security-constraint...

2003-07-31 Thread Rob Tomlin

 ah the old IE + SSL + cacheing problem ;)

I am not using SSL,


I haveadding the suggested code it does not 
solve the problem...

Cheers

Rob

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



RE: File cannot be download with security-constraint...

2003-07-31 Thread Rob Tomlin
 ah the old IE + SSL + cacheing problem ;)

This seems to solve the problem:

response.setHeader(Cache-Control, public);

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



Re: File cannot be download with security-constraint...

2003-07-31 Thread Jon Wingfield
Cool. Was just writing a response about the headers tomcat adds when 
using a security restraint. But you've already worked it out...

I've only seen the problem when using IE with SSL + security constraint 
but i guess it's more of a general problem. :(

Jon

Rob Tomlin wrote:
ah the old IE + SSL + cacheing problem ;)


This seems to solve the problem:

response.setHeader(Cache-Control, public);

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





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