开发者

swf sending servlet doesn't work on IE

开发者 https://www.devze.com 2022-12-21 22:58 出处:网络
im trying to render the swf on jsp page i can show local files \"waf.swf\" but whenever i use the servlet addres开发者_JS百科s it fails on IE but works on firefox

im trying to render the swf on jsp page i can show local files "waf.swf" but whenever i use the servlet addres开发者_JS百科s it fails on IE but works on firefox

this is the servlet code

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

The other suspect thing is the Content-Disposition header. You didn't explicitly set it to inline. You never knows with IE, so try to set it explicitly to inline or just outcomment it for testing purposes.

By the way, the DataInputStream is superfluous here. You didn't take benefit of any of its methods. Just get rid it and stick to FileInputStream. Or, to improve performance a bit more, wrap with BufferedInputStream instead (and do the same with BufferedOutputStream for the response).


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.

thanks !!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号