简体   繁体   English

swf发送servlet在IE上不起作用

[英]swf sending servlet doesn't work on IE

im trying to render the swf on jsp page i can show local files "waf.swf" but whenever i use the servlet address it fails on IE but works on firefox 我试图在jsp页面上呈现swf,我可以显示本地文件“ waf.swf”,但是每当我使用servlet地址时,它在IE上都会失败,但可以在firefox上运行

this is the servlet code 这是servlet代码

ServletOutputStream out = response.getOutputStream();
response.setContentType("application/x-shockwave-flash");
response.setContentLength(length);
response.setHeader("Content-Disposition", "filename=\"" + file.getName() + "\"" );
response.setHeader("cache-control", "no-cache");
byte[] bbuf = new byte[1024];
DataInputStream in = new DataInputStream(new FileInputStream(file));

while ((in != null) && ((length = in.read(bbuf)) != -1))
  out.write(bbuf,0,length);

in.close();
out.flush();
out.close();

Ensure that the Content-Length is correct on the exact bit. 确保“ Content-Length正确的位上正确 For testing purposes you can outcomment it. 出于测试目的,您可以将其注释掉。 The application can only not calculate anymore how long it will take before the loading is finished, but it should work. 该应用程序无法再计算加载完成之前将花费的时间,但是它应该可以工作。 If the content length was wrong, then either the browser would expect more bytes to come and is thus waiting (when content length is bigger than actual file length), or the browser will abort the download and end up with an incomplete flash file (when content length is smaller than actual file length). 如果内容长度错误,则浏览器会期望会有更多字节进入等待状态(当内容长度大于实际文件长度时),或者浏览器将中止下载并最终生成不完整的Flash文件(当内容长度小于实际文件长度)。

The other suspect thing is the Content-Disposition header. 另一个可疑的是Content-Disposition标头。 You didn't explicitly set it to inline . 您没有将其显式设置为inline You never knows with IE, so try to set it explicitly to inline or just outcomment it for testing purposes. 您从不了解IE,因此请尝试将其显式设置为inline或仅出于测试目的而将其注释掉。

By the way, the DataInputStream is superfluous here. 顺便说一下, DataInputStream在这里是多余的。 You didn't take benefit of any of its methods. 您没有利用其任何方法。 Just get rid it and stick to FileInputStream . 只要摆脱它,并坚持FileInputStream Or, to improve performance a bit more, wrap with BufferedInputStream instead (and do the same with BufferedOutputStream for the response). 或者,为了进一步提高性能,请改用BufferedInputStream包装(并使用BufferedOutputStream进行响应)。

I tried everything you offered. 我尝试了您提供的一切。 It didn't help. 它没有帮助。 I tried changing the header cache to: 我尝试将标头缓存更改为:

response.setHeader("cache-control", "must-revalidate");

i have absolutely no idea why, but it finally works on IE. 我完全不知道为什么,但最终可以在IE上运行。

thanks !! 谢谢 !!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM