A context root is a Java servlet-ism, which allows the container to route incoming requests to the correct web app. In HTML-land if you're using relative URLs, you generally never have to worry about this because the right value will be used automatically. It's a little more complicated for a non-HTML client. The context root for a web app can either be empty (i.e. /) or non-empty (i.e. /MyApp), and on the client when a swf loads, it can inspect its URL but it doesn't have any way to know what the server-side context root is. The MessageBrokerServlet that processes HTTP-based requests from Flex clients is not relative to where the swf was loaded from. You can define its path, which will generally be something like: http://{server}:{port}/{context.root}/messagebrokerservlet, but it could be anything. To send a request to it successfully, the client needs to use the correct context root. Take your URL below for example, http://localhost:8080/MyApp/..., is the context root / or is it /MyApp - who knows? Only the server. So unlike server name and port, the swf can't dynamically determine the correct context root value at runtime on the client.
This means you need to either: 1. Specify it at compile time by hardcoding the proper context root into the URL in your services-config.xml file, or by using a {context.root} token in your URL in services-config.xml and passing the desired value at compile time using the mxmlc -context-root flag. 2. Hardcode it into your client side ActionScript code. 3. Use the web tier mxmlc compiler which can replace a {context.root} token with the correct value using HttpServletRequest#getContextPath() when you request a .mxml in the browser Seth From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Robert Csiki Sent: Friday, May 16, 2008 1:45 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Is the context-root value burnt into SWF? Hi there, Say I'm using a context root value "MyApp" when compiling my LCDS-based Flex application. I package everything into an archive called "MyApp.war", depoly it on my Tomcat, startup tomcat, access the application using http://localhost:8080/MyApp, everything works fine (I have an index.html there that serves up the SWF) Now, if I want to deploy using a different context root for my application (say "MyApp1")... call it using the URL http://localhost:8080/MyApp1 ... nothing would work this time. The SWF still gets loaded, and that's it. It seems this context-root value that's set in flex_config.xml gets somehow burnt in the SWF? what can I do to have the app running under a different context root, without the need to rebuild the SWF? Also, a question: why this context-root configuration is required in Flex environment? An application normally auto-detects it's context root at runtime. An application is usually untied from a specific context root and can be deployed using any context root. Thanks, Robert