Direct Web Remoting
| Company type | Open-source software |
|---|---|
| Industry | Software development |
| Founded | 2004 |
| Founder | Joe Walker |
| Products | Java library for Ajax web applications |
Direct Web Remoting (DWR) is an open-source Java library designed to assist developers in creating web applications utilizing Ajax techniques. It enables client-side scripts to call Java methods hosted on a web server as though they were executed locally, thereby simplifying the development of interactive web pages. Initiated by Joe Walker in 2004, the initial version, DWR 1.0, became publicly available on August 29, 2005.
Application
DWR offers the following capabilities:
- Enables JavaScript to asynchronously fetch data from servlet-based servers through Ajax.
- Provides tools for effortless dynamic updates of web content using its JavaScript utilities.
What sets DWR apart is its ability to dynamically produce JavaScript proxies from Java classes, facilitating smooth integration of server-side Java logic within browser environments. Developers specify which Java classes are accessible from the client side for security purposes, commonly configured via web.xml or dwr.xml files.
This mechanism resembles conventional remote procedure call systems such as RMI or SOAP, but it operates over standard web protocols without necessitating any browser extensions or plug-ins.
Focusing on delivering an intuitive programming model rather than exposing the complexity of browser-server communication, DWR resolves the disparity between Ajax’s asynchronous nature and Java’s synchronous execution by introducing a CallBack Method parameter. This callback function processes the server response asynchronously once it arrives, enabling effective non-blocking interactions.
Example of a callback usage: <syntaxhighlight lang="javascript"> MJavaClassOnJs.getListProducts(selectedCategory, {
callback: function(returnedList) {
dwr.util.addOptions(myComboId, returnedList, "productId", "productName")
}
}) </syntaxhighlight>
Starting with version 2.0, DWR incorporates support for Comet technology (also known as "Reverse Ajax"), which permits server-side Java to push JavaScript commands directly to clients’ browsers, thereby enhancing capabilities for real-time web applications.
References
Bibliography