5 Replies Latest reply on Jun 9, 2008 1:45 PM by BeniRose

    Cross Domain policy for Java Servlets

    BeniRose Level 1
      I'm trying to have my flash file load in an "xml" file, which is actually a Java Servlet dynamically compiling an xml file. My problem is that the Java Servlet is running on a different domain than the flash. I'm currently running the servlet on Tomcat, but will be running it on Websphere when we go to production. Has anyone had any experience with cross domain policies for Java Servlets? I've tried placing a cross domain policy in pretty much every folder, but can't seem to get this to work. Anyone who's had any similar problems, I would really appreciate any advice.
        • 1. Re: Cross Domain policy for Java Servlets
          Greg Dove Level 4
          If you post a link to an example that shows it not working I may be able to help. The default location is the web document root of the external domain, but often its easier to see what's not working by looking watching what's not working.
          • 2. Re: Cross Domain policy for Java Servlets
            BeniRose Level 1
            Unfortunately it's on an intranet so I can't show you, but it's pretty much just that the XML file is not loading, and it's because of the domain. I know this because in development, we have the servlets and flash running on the server, but have multiple domains to access it. For example, I can access the site as well as the servlets by just going to http://servername or by going to http://servername.main.corp.

            Well the calls to the servlets were previously hardcoded in the flash with absolute URLs, as http://servername.main.corp/servlets/DoSomething. When I accessed the site at http://servername.main.corp, the swf worked properly and loaded the data correctly. However, when I accessed the site at http://servername, the swf would hang up on the loading stage. So it's pretty clear that the domain is the issue.

            As I said, I'm running tomcat, so there's not really a "web document root", especially since I'm aliasing tomcat in apache webserver via JK_mod. So when I type in http://servername.main.corp/servlets/DoSomething, it makes the request to apache webserver, which then hands off the request to tomcat which has a web.xml file configuring aliases for itself!

            However, in production, I will be running websphere, and I have no idea how that folder structure is set up, so maybe it will be easier to figure out where to place my cross domain policy.
            • 3. Re: Cross Domain policy for Java Servlets
              BeniRose Level 1
              Like I said, I'm side chaining tomcat via apache webserver, so I don't know where my "root" would be, if it would be the root of apache (since that's what's taking the request) the root of tomcat (since it's aliasing to that, so it's really passing it off...but where the hell is the root of tomcat?) or the root of the servlet (since web.xml sets up alias folders for each servlet).
              • 4. Re: Cross Domain policy for Java Servlets
                Greg Dove Level 4
                Let's turn this around rather than getting into the server details: A quick way to see where flash is looking for the crossdomain.xml is to use Firefox with the Firebug plugin and watch the http requests coming from the browser. You will see where flash is looking for the crossdomain.xml file and not finding it. That's the best way to check quickly.
                • 5. Re: Cross Domain policy for Java Servlets
                  BeniRose Level 1
                  I actually got it working by placing the crossdomain.xml in the root of apache server, since the request was going there before getting transfered to the tomcat server. However, this is because they're both using the same domain, on production they will be two different domains, so I'm trying to set up an environment that will emulate that. I tried pointing the flash files to the same domain but with the port that goes directly to tomcat, but this worked without ANY crossdomain policies!!

                  But thanks for your guidance, I think you've helped me in a few binds in the past! I'll check out firebug for sure, it's one of my favourite tools, I'm surprised I didn't think to use it myself. Thanks again!