This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SWF contents are not visible when navigating through Servlet.

 
Shasank Sekhar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Shasank Sekhar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The source of the rendered page is more interesting. What does that look like?
 
Shasank Sekhar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic