Wednesday, July 23, 2014

Integration of DWR using DWRSpringServlet

DWR is a Easy Ajax for Java. To know more click here.

In this article we will see sample codes for integration of DWR with DWRSpringServlet

Step 1 - Create a web project in eclipse.

Step 2 - Add below Spring libraries

  • Spring Core libraries
  • Spring Web libraries
  • Spring AOP libraries
Step 3 - Add dwr.jar
Download appropriate version of dwr.jar and add it in your application classpath. For example DWR 3 requires Spring version 2.5 or greater.

Step 4 - Create dependent files

web.xml
The DwrSpringServlet can be used if you are not using Spring MVC. This servlet gains access to the Spring context configured in your web.xml. You can create your own context file, in our case it is dwrcontext.xml.


dwrcontext.xml


DWRService.java


index.jsp


Step 5 - Deploy the project in tomcat (or any other web server) and check the output