DWR : A paradigm shift in web development
by Jerome Kehrli
Posted on Thursday Apr 29, 2010 at 04:57PM in Java
I discovered DWR recently and I believe it to be an amazing breakthrough in the world of HTTP client-server comunications.
First what is DWR ?
DWR stands for Direct Web Remoting - Easy Ajax for Java.
Quoting the official website :
Read this : http://directwebremoting.org/dwr/introduction/index.html.
What's the point ?
Pretty nifty, huh ?
Obviously real-life scenarii suffer from some limitations. For instance, for this to work efficiently, a thorough SOA design is required on both sides to minimize round-trips between the client and the server.
Why is it cool ?
It's cool ... because it's quite obviously cool. Let's look at the alternatives:
For ages we have been using CGI scripts, then
PHP, then even
JSP or lately
Then some smart boys came up with AJAX ... Well
XMLHttpRequest actually is a good thing (although it's just an easier way to do just the same thing others were doing with hidden iframes since ages).
But let's face it, there is something with all of this still far from ideal. The problem comes with the
Happily, a lot of web developers understand this perfectly nowadays and JSON/RPC is becoming a de-facto standard for cutting-edge modern web developments. The server side backend usually relies on simple
REST services and that is a huge simplification as well over the overwhelming complexity of Web-services.
And this is where I believe is the paradigm shift. DWR makes it feel like the client-server separation vanishes. It really feels like everything now stands in one single unified place at the client side.
How does it work ?
DWR consists of two main parts:
- A Java Servlet running on the server that processes requests and sends responses back to the browser.
DWR used JSON to transmit the data over the network to the server. On the server sides it provides the completely JSON to Plain Old Java Object serialization system.
Every Java object which is intended to be available for remote method calls on the client application should be declared in the