Search code examples
javaajaxdwr

Is it possible to use DWR if the DWR servlet is deployed in a different war?


I wanted to use DWR from web application A, but the DWR servlet is in web application B.

Is this possible? Is there any work-around?

Thanks!


Solution

  • Yes, totally you can do that.

    When you include the generated javascript file to be used in application A, you need to specify the B application path (where the dwr servlet is deployed) as follows:

    <script type='text/javascript' src='[application B path]/dwr/interface/[javascript class name].js'></script>
    

    [application B path] would be something like http://my-domain.com/AppB

    [javascript class name] would be as delcared in dwr.xml on application B

    <create creator="new" javascript="[javascript class name]">
        <param name="class" value="com.my-domain.Class"/>
    </create>
    

    and you can use any core javascript classes as follows:

    <script type='text/javascript' src='[application B path]/dwr/engine.js'></script>
    <script type='text/javascript' src='[application B path]/dwr/util.js'></script>