aspose file tools*
The moose likes Servlets and the fly likes SWF contents are not visible when navigating through Servlet. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "SWF contents are not visible when navigating through Servlet." Watch "SWF contents are not visible when navigating through Servlet." New topic
Author

SWF contents are not visible when navigating through Servlet.

Shasank Sekhar
Greenhorn

Joined: May 03, 2011
Posts: 7
Redirecting to a JSP page/HTML page containing SWF object from a Servlet hides the SDF contents.
EX:
===
1) From servlet I move to page:index.html

response.sendRedirect("index.html");

2) Inside index.html there is a embed SWF. Other contents are visible but SWF content is not.

Please help.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Check your Flash player - do you have one? Is it a recent enough version to run your SWF? Do you use JavaScript to launch your SWF?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Shasank Sekhar
Greenhorn

Joined: May 03, 2011
Posts: 7
Actually SWF file is generated and run quite well. I have all setup. Event when i open the index.html, every thing is fine.

But Issue comes when i navigate to index.html from one Servlet(either by response.sendRedirect or by RequestDispatcher).

Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

From the client's point of view there is no difference if you use sendRedirect. What does the source of the page look like? Does it include the object tag?
Shasank Sekhar
Greenhorn

Joined: May 03, 2011
Posts: 7
I have 3 files. I am calling the index.html from a ServletFilter. Please check the contents of cosde below.

web.xml
======
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>UserFilter</filter-name>
<filter-class>com.filter.UserFilter</filter-class>
<init-param>
<param-name>Redirect_Page</param-name>
<param-value>index.html</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UserFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>


<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>


UserFilter.java
=============
package com.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class UserFilter implements Filter {

FilterConfig filterConfig = null;
@Override
public void init(FilterConfig config) throws ServletException {
filterConfig = (FilterConfig) config;
}

@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {

boolean authorized = false;
HttpServletRequest httpRequest = ((HttpServletRequest)request);
HttpServletResponse httpResponse = ((HttpServletResponse)response);
HttpSession session = httpRequest.getSession(false);

if (session != null) {
String user = (String) session.getAttribute("USERID");

if (user != null) {
authorized = true;
} else {
user = ((HttpServletRequest)request).getParameter("userId");
if (user != null) authorized = true;
}
}


String page = filterConfig.getInitParameter("Redirect_Page");

String URI = httpRequest.getRequestURI();

if (authorized || URI.endsWith(page)) {
chain.doFilter(request, response);
return;
} else {

if (page != null && !"".equals(page)) {

httpResponse.sendRedirect("/AppName/"+page);
//chain.doFilter(request, response);
return;
}
}
}

@Override
public void destroy() {}
}


index.html
=========
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="fx/swfobject.js"></script>

<script type="text/javascript">
var swfVersionStr = "10.0.0";
var xiSwfUrlStr = "playerProductInstall.swf";
var flashvars = {};
var params = {};
params.quality = "high";
params.bgcolor = "#ffffff";
params.allowscriptaccess = "sameDomain";
params.allowfullscreen = "true";
var attributes = {};
attributes.id = "LCDSConfigured";
attributes.name = "LCDSConfigured";
attributes.align = "middle";
swfobject.embedSWF(
"fx/Logon.swf", "flashContent",
"100%", "100%",
swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes);
swfobject.createCSS("#flashContent", "display:block;text-align:left;");
</script>
</head>
<body>
<div id="flashContent">
<p>
To view this page ensure that Adobe Flash Player version
10.0.0 or greater is installed.
</p>
<script type="text/javascript">
var pageHost = ((document.location.protocol == "https:") ? "https://" : "http://");
document.write("<a href='http://www.adobe.com/go/getflashplayer'><img src='"
+ pageHost + "www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a>" );
</script>
</div>

<noscript>
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%" id="LCDSConfigured">
<param name="movie" value="fx/Logon.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="fx/Logon.swf" width="100%" height="100%">
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<!--<![endif]-->
<!--[if gte IE 6]>-->
<p>
Either scripts and active content are not permitted to run or Adobe Flash Player version
10.0.0 or greater is not installed.
</p>
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflashplayer">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash Player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</noscript>
</body>
</html>
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

The source of the rendered page is more interesting. What does that look like?
Shasank Sekhar
Greenhorn

Joined: May 03, 2011
Posts: 7
You mean the source of index.html!!!

The codes in index.html just embeds one swf file(Logon.swf) nothing else. The contents of swf may be anything and so also visibility.
Shasank Sekhar
Greenhorn

Joined: May 03, 2011
Posts: 7
I share one more thing that the swf file is generated from FlashBuilder4. It's a LoginForm and the other contents to embed the swf are also auto generated by Flash Builder.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Shasank Sekhar wrote:You mean the source of index.html!!!


Yes, I do.


When you right click on the area where the SWF should be what context menus do you get? Any JavaScript errors being reported (assuming your browser is configured to report them)?
Shasank Sekhar
Greenhorn

Joined: May 03, 2011
Posts: 7
May be this is strange but there is no JS issue and the page source contains all the codes that i share above but dont display the SWF in the page. Even right click on the page gets the menu of normal HTML page where i expect SWF and right click on the page to display Flash menu.

I google this issue a lot but dont get much help. Somewhere i found that due to security reasons when we navigate through a Servlet the Tomcat Server intelligently handle the cookie and dont include the SWF contents. IF so there must be some set up by which we can solve this issue.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

So you are getting a Flash menu when you right click on the SWF? That sounds like its a problem with the Flash application itself. Have you tried using the debug player?
Shasank Sekhar
Greenhorn

Joined: May 03, 2011
Posts: 7
Still you don't get it...

SWF is not embed to the page(index.html). Ok let me brief,

From the ServletFilter I can move to index.html either through IF or ELSE(Check below code),



If i navigate to index.html and control pass through,
1) IF then the SWF in index.html is visible.
2) ELSE then the SWF in index.html is not visible.

This may be due to security reason or something else(No idea).
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Sorry, I'm asking the question because I don't understand what you mean by the sentence:

Even right click on the page gets the menu of normal HTML page where i expect SWF and right click on the page to display Flash menu.


Your code snippet suggest you redirect to a different web application if authorized variable is false. So the obvious question is does this different application contain the SWF? There is nothing a filter can do to influence the behaviour of a client side technology, the only think it can change is the request itself. If you are correctly serving your SFW file and it is not displaying this suggests a problem with the SWF itself, in which case use the debug player. It it is not being served your request is wrong so check what it is you are really requesting (fiddler or some similar tool will show you that).
 
wood burning stoves
 
subject: SWF contents are not visible when navigating through Servlet.