Remoting Options

DWR provides two remoting options:

1) DWR native - By default DWR uses a superset of JSON that we like to call JavaScript. This was initially done to cope with recursive data, XML objects, etc., which the original JSON specifications had a difficult time dealing with. In this remoting mode DWR's client side  engine (engine.js) handles preparing and executing the call to the server.  Most of the documentation on this site deals with DWR native. 

2) JSON/JSONP - In DWR 3 a JSON/JSONP RESTian API has been added that allows users to access Java services exposed to DWR via an URL: DWR will reply with a JSON structure containing the result of calling ClassName.methodName("param1", "param2");

This allows for seamless integration with JavaScript toolkits (DOJO, ExtJs, jQuery, etc.) while eliminating the need for the developer to convert the return types of their exposed Java methods into JSON manually - DWR's server engine handles this.

Getting Started with JSON/JSONP

In order to enable JSON/JSONP you must add the jsonpEnabled init-param to your DWR servlet definition in your web.xml.  This parameter activates the JSON/JSONP service.
<display-name>DWR Servlet</display-name>
<description>Direct Web Remoter Servlet</description>

For an example of the JSON/JSONP functionality you can view this demo which uses JQuery. A similar example using DOJO is also avaiable. Both of these examples are available for download in our dwr.war.