what’s the recommended method to load an SWF file in my page ?
just to use HttpServletResponse.getWriter and to print with it the SWF object, or is there a more efficient method ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If it is a static SWF file, simply place it in a publicly browsable path and allow Tomcat to serve it as a static file. If you are generating an SWF file dynamically,
ServletResponse.getWriter()is perfectly fine as long as you remember to set theContent-typeHTTP header toapplication/x-shockwave-flash. You can do that just before writing to the output stream withServletResponse.setContentType()like this:You may also want to think about setting some HTTP caching related headers such as
Cache-ControlandExpiresif you want browsers to be able to cache your SWF files. You can do that withHttpServletResponse.setHeader()orHttpServletResponse.addHeader(). For the case of a static SWF file, you will have to set caching headers in aFiltermapped with a<url-pattern>.Another point worth mentioning is that referencing SWF content in a cross browser friendly way that bypasses an irritating extra-click behavior in some versions of MSIE has become some kind of black magic. I recommend using the SWFObject library (hosted on Google Code) to abstract the ugliness away.