DWR

Facilitate multiple servers with absolute urls

Details

  • Type: New Feature New Feature
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 2.0.5, 3.0.M1
  • Fix Version/s: 4.0
  • Component/s: None
  • Description:
    Hide
    Although it is not impossible to invoke DWR services from two different domains, it is quite cumbersome.
    There are two ways to do it AFAIK:
    1. if you have one remote server that is different from the domain that the page is running on, then you can set an init-param in your web.xml, specifying an overridePath
        This will be picked up by DefaultRemoter. But you can only specify it once, so you cannot invoke DWR services from two different servers.

    2. by changing the _path of your service after loading the DWR interface stub in your html page
       For example, consider a service "MooService" running on host-2 used on a page hosted on host-1 (the context root of the MooService is the server root)

    <script src="http://host-2/dwr/interface/MooService.js"></script>
    MooService._path="http://host-2/dwr"; // was "/dwr"

    That is cumbersome, since you have to do that for every service. It is also quite easy to improve.

    I've attached a new version of InterfaceHandler based on DWR-2.0.5 (I've checked that DWR-3.0.M1.RC2 has the same issue)
    By default, it does nothing special (don't want to break an existing installations)

    But when your web.xml specifies the following init-param:

    <init-param>
        <param-name>absoluteUrlPaths</param-name>
        <param-value>true</param-value>
    </init-param>

    .. then it will output full urls in the generated interface scripts, so they will always be correct.

    N.B. this doesn't violate cross-site scripting constraints since the interface stub that invokes the service is loaded from the same server as the DWR services that it invokes.

    Show
    Although it is not impossible to invoke DWR services from two different domains, it is quite cumbersome. There are two ways to do it AFAIK: 1. if you have one remote server that is different from the domain that the page is running on, then you can set an init-param in your web.xml, specifying an overridePath     This will be picked up by DefaultRemoter. But you can only specify it once, so you cannot invoke DWR services from two different servers. 2. by changing the _path of your service after loading the DWR interface stub in your html page    For example, consider a service "MooService" running on host-2 used on a page hosted on host-1 (the context root of the MooService is the server root) <script src="http://host-2/dwr/interface/MooService.js"></script> MooService._path="http://host-2/dwr"; // was "/dwr" That is cumbersome, since you have to do that for every service. It is also quite easy to improve. I've attached a new version of InterfaceHandler based on DWR-2.0.5 (I've checked that DWR-3.0.M1.RC2 has the same issue) By default, it does nothing special (don't want to break an existing installations) But when your web.xml specifies the following init-param: <init-param>     <param-name>absoluteUrlPaths</param-name>     <param-value>true</param-value> </init-param> .. then it will output full urls in the generated interface scripts, so they will always be correct. N.B. this doesn't violate cross-site scripting constraints since the interface stub that invokes the service is loaded from the same server as the DWR services that it invokes.
  1. InterfaceHandler.java
    (4 kB)
    Erwin Bolwidt
    07/Sep/08 7:36 PM
  2. InterfaceHandler.patch
    (2 kB)
    Erwin Bolwidt
    08/Sep/08 12:51 PM

Issue Links

Activity

Hide
Erwin Bolwidt added a comment - 07/Sep/08 7:36 PM

Modified InterfaceHandler. It adds support for a web.xml init parameter named "absoluteUrlPaths" that accepts a boolean true/false parameter value. By default it is "false" to preserve backward compatibility.

When true, the generated interface scripts will output a full url including scheme (http/https), host name and port number.

Show
Erwin Bolwidt added a comment - 07/Sep/08 7:36 PM Modified InterfaceHandler. It adds support for a web.xml init parameter named "absoluteUrlPaths" that accepts a boolean true/false parameter value. By default it is "false" to preserve backward compatibility. When true, the generated interface scripts will output a full url including scheme (http/https), host name and port number.

People

Dates

  • Created:
    07/Sep/08 7:34 PM
    Updated:
    01/Dec/09 7:00 PM