Itegrating DWR (Direct Web Remoting) with Spring
Hi Springers, I have used DWR (Direct Web Remoting) in my last project which was pretty interesting and I want to share the simplest way of using DWR with spring application. Download the latest version of dwr.jar from here. And put it in the /WEB-INF/lib folder. I have used DWR 2.0.5.
Add the following lines in your web.xml
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<display-name>DWR Servlet</display-name>
<servlet-class>
org.directwebremoting.servlet.DwrServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
Now create a dwr.xml in the WEB-INF folder alongside web.xml and add the following line in that file.
<!DOCTYPE dwr PUBLIC
"-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN"
"http://getahead.org/dwr/dwr20.dtd">
<dwr>
<allow>
<create creator="new" javascript="JDate">
<param name="class" value="java.util.Date"/>
</create>
<create creator="new" javascript="Demo">
<param name="class" value="your.java.Bean"/>
</create>
</allow>
</dwr>
To check go to the following URL.
http://localhost:8080/[YOUR-WEBAPP]/dwr/
You should see a page showing you the classes that you’ve selected.
To learn detail about DWR please visit the documentation site of DWR.

I am a simple man working in IT field. I love Music, playing soccer, traveling new places. By profession I am a software engineer and enjoy my job. Currently I am doing my M Sc in Software Engineering in Blekinge Institute of Technology, Sweden. I love researching on new technologies such as programming languages, architectures, tools and techniques.
Recent Comments