DWR – Easy AJAX for Java

DWR is a really fantastic library for Java: it allows to write JavaScript applications in web browsers that will directly and almost transparently call Java-methods of objects that live in the Java-Servlet-Container (e.g. Tomcat) as part of the web-application.

DWR, which is short for “Direct Web Remoting”, acts as a JavaScript-to-Java RPC marshaller on the client side, using the common Ajax XMLHttpRequest object, hiding any marshalling. In fact, it is as simple as adding dwr.jar to your web-application’s WEB-INF/lib directory and configuring an XML file to define which Java-objects are exposed remotely.

It also provides a web-interface for debugging your exposed objects by providing a way to call its methods manually without the need of your own testing-JavaScript application.

Ajax is a buzz word at the moment, despite the fact that the technologies it comprises of are quite old and well established. Regardless of how you think about Ajax and the hype around it (and Web2.0), there is one simple case where every web-developer should consider the usage of Ajax: input form validation. And DWR makes semi-clientside/serverside validation of forms a pure fun to code. While the data is still submitted to the server for validation (allowing you to fully utilize existing validation code of your Java web-application) from the user’s point-of-view the server-round-trip is spared, improving usability and user-experience.
Anyone knows if this library has been ported to .NET? 😉

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.