2004/12/15

Direct Web Remoting: Call server-side Java from JavaScript

URL: http://www.theserverside.com/news/thread.tss?thread_id=30520
Direct Web Remoting Home: http://dwr.dev.java.net/

DWR comes as a simple jar file and a few lines to add to your web.xml file to configure the remoted classes. In a web page you add a couple of <script> tags to indicate which classes you wish to import and can then call your Java code directly from Javascript. More detailed instructions are available on the DWR site.

The Javascript works by dynamically creating an iframe through which it calls the DWR servlet with instructions about what Java code to call. The DWR servlet marshalls the parameters, calls the server-side Java code and returns the reply to the iframe, which triggers an onload, which returns the reply to the calling Javascript.

No comments: