Direct Web Remoting

indexadjustmentInternet et le développement Web

13 nov. 2013 (il y a 8 années et 3 mois)

363 vue(s)

Direct Web Remoting

Rajesh R


What is DWR?

Why DWR?

Reverse AJAX


What is DWR?

Is a Java and JavaScript open source library which
allows you to write Ajax web applications

Specifically designed with Java technology in mind

> “Easy AJAX for Java”

Allows JavaScript code in a browser to use Java
methods running on a web server just as if they
were in the browser

> Why it is called “Direct remoting”

Why DWR?

Without DWR, you would have to create many Web
application endpoints (servlets) that need to be
address'able via URI's

What happens if you have several methods in a
class on the server that you want to invoke from the

> Each of these methods need to be addressable via URI whether
you are using
directory or client side only toolkit
such as Dojo or Prototype

> You would have to map parameters and return values to HTML

input form parameters and responses yourself

DWR comes with some JavaScript utility functions


A Java Servlet running on the server
that processes incoming DWR
requests and sends responses back to
the browser.

JavaScript running in the browser that
sends requests and can dynamically
update the webpage

JS to Java

Reverse Ajax

Reverse Ajax is the biggest new
feature in DWR 2.0

It gives you the ability to
asynchronously send data from a web
server to a browser.

Java to JS: Reverse Ajax

allows Java code running on the server to find out what clients are viewing
certain pages, and to send to them JavaScript, generated either manually or
using a Java API

Dynamic JS

DWR generates dynamic JS based on the
Java Classes

The DWR Engine then does some Ajax
magic to make it feel like the execution is
happening on the browser, but in reality the
server is executing the code and DWR is
marshalling the data back and forwards.


Call Java Functions like RMI or Soap

Automatically create Java versions of

Expose business methods through JS

Supported Environment

DWR requires JDK1.3 or later






Browser Support

Firefox 1.0 and above

Internet Explorer 6.0 and above

Opera 8.0 and above

Safari 1.3 and above