Practical DWR 2 Projects


The Ajax craze is sweeping the world, and there is no shortage of libraries from which to choose to make it all easier to develop. One of those libraries has risen near the top in the Java space, and that library is DWR. DWR, or Direct Web Remoting, allows you to treat your Java classes running on the server as if they were local objects running in the browser, bringing the full power of your server–side business logic to the client without the...

See more details below
$34.77 price
(Save 26%)$46.99 List Price
Other sellers (Paperback)
  • All (30) from $1.99   
  • New (15) from $1.99   
  • Used (15) from $1.99   
Sending request ...


The Ajax craze is sweeping the world, and there is no shortage of libraries from which to choose to make it all easier to develop. One of those libraries has risen near the top in the Java space, and that library is DWR. DWR, or Direct Web Remoting, allows you to treat your Java classes running on the server as if they were local objects running in the browser, bringing the full power of your server–side business logic to the client without the usual problems that entails. In this book, you will:

  • Explore DWR and all it offers
  • Find six full, working applications that use DWR, instead of a lot of theoretical musings
  • Learn by example, more importantly, by doing, as you tear the applications apart, see what makes them tick, and even extend them at your own pace

In the end, you’ll have a great feel for what DWR offers and how Ajax can bring the world of Web 2.0 to your doorstep, and you’ll have a good time doing it.

What you’ll learn

  • Call a server–side object in a snap and make it look like any local JavaScript call to boot
  • Provide a strong security mechanism for securing your server-side code
  • Integrate with many of the most popular frameworks out there
  • Provide not only Ajax but Comet capabilities (sometimes called reverse Ajax)
  • Dig into Ajax using DWR in a practical and hacking kind of way starting with a webmail client and Wiki projects
  • Build a simple file manager application and an online timesheet system
  • Complete a DWR–based game project

Who this book is for

Web application developers, senior projects leads, and application architects.

Read More Show Less

Product Details

  • ISBN-13: 9781590599419
  • Publisher: Apress
  • Publication date: 1/24/2008
  • Series: Expert's Voice in Java Series
  • Edition number: 1
  • Pages: 568
  • Product dimensions: 7.00 (w) x 9.20 (h) x 1.30 (d)

Meet the Author

Frank W. Zammetti is a web architect specialist for a leading worldwide financial company by day, and a PocketPC and open-source developer by night. He is the founder and chief software architect of Omnytex Technologies, a PocketPC development house.

He has over 12 years of "professional" experience in the information technology field, and over 12 more of "amateur" experience. He began his nearly life-long love of computers at age 7, when he became one of four students chosen to take part in his school district's pilot computer program. A year later, he was the only participant left! The first computer Frank owned was a Timex Sinclair 1000 in 1982, on which he wrote a program to look up movie times for all of Long Island (and without the 16k expansion module!). After that, he moved on to a Commodore 64 and spent about 4 years doing nothing but assembly programming (games mostly). He finally got his first IBM-compatible PC in 1987, and began learning the finer points of programming (as they existed at that time!).

Frank has primarily developed web-based applications for about 8 years. Before that, he developed Windows-based client/server applications in a variety of languages. Frank holds numerous certifications including SCJP, MCSD, CNA, i-Net+, A+, CIW, MCP, and numerous BrainBench certifications. He is a contributor to a number of open source projects, including DataVision, Struts, PocketFrog, and Jakarta Commons. In addition, Frank has started two projects: Java Web Parts and The Struts Web Services Enablement Project. He also was one of the founding members of a project that created the first fully functioning Commodore 64 emulator for PocketPC devices (PocketHobbit).

Frank has authored various articles on topics that range from integrating DataVision into web apps, to using Ajax in Struts-based applications. He is working on a new application framework specifically geared to creating next-generation web applications.

Read More Show Less

Table of Contents

Foreword     xiii
About the Author     xv
About the Technical Reviewer     xvii
About the Illustrator     xix
Acknowledgments     xxi
Introduction     xxiii
Setting the Table
An Introduction to Ajax, RPC, and Modern RIAs     3
A Brief History of Web Development: The "Classic" Model     3
Dawn of a Whole New World: The PC Era     5
Yet Another Revolution: Enter the Web     7
What's So Wrong with the Classic Web?     11
Enter Ajax     14
Why Is Ajax a Paradigm Shift? On the Road to RIAs     18
The Flip Side of the Coin     23
Let's Get to the Good Stuff: Our First Ajax Code, the Manual Way     25
A Quick Postmortem     29
Hey, I Thought This Was Ajax?!?     30
Cutting IN the Middle Man: Ajax Libraries to Ease Our Pain     33
Alternatives to Ajax     36
Hmm, Are We Forgetting Something? What Could It Be? Oh Yeah, DWR!     39
Summary     40
Getting to Know DWR     43
First Things First: Why DWR at All?     43
DWR: RPC on Steroids for the Web     45
DWR Architectural Overview     47
Getting Ready for theFun: Your DWR Development Environment     49
A Simple Webapp to Get Us Started     52
Getting the Lay of the Land: Directory Structure     52
From Code to Executable: Ant Build Script     53
Application Configuration: web.xml     54
The Markup: index.jsp     55
On the Server Side:     56
The Workhorse:     58
It's Alive: Seeing It in Action     60
Adding DWR to the Mix     61
The DWR Test/Debug Page     65
Configuring DWR Part 1: web.xml     67
Configuring DWR Part 2: dwr.xml     70
Built-in Creators and Converters     75
The [left angle bracket]init[right angle bracket] Section     76
The [left angle bracket]allow[right angle bracket] Section     76
The [left angle bracket]signatures[right angle bracket] Section     79
Interacting with DWR on the Client     81
Basic Call Syntax     81
Call Metadata Object Approach     82
A Word on Some Funky Syntax     83
Setting Beans on a Remote Object     83
Extended Data Passing to Callbacks     87
Interacting with DWR on the Server     88
DWR Configuration and Other Concepts: The engine.js File     90
Call Batching     92
A Quick Look at util.js, the DWR Utility Package     92
Summary     94
Advanced DWR     95
Locking the Doors: Security in DWR     95
Deny by Default     96
J2EE Security and DWR     98
When Perfection Is Elusive: Error Handling in DWR Applications     101
Handling Warnings     102
Handling Errors     102
Handling Exceptions     102
Edge Cases: Improper Responses     102
The Mechanics of Handling Exceptional Situations     105
Another Word on Exceptions     106
Help from Elsewhere: Accessing Other URLs     107
Turning the Tables: Reverse Ajax     109
Polling     111
Comet     112
Piggybacking     114
The Code of Reverse Ajax     115
Don't Go It Alone: Integration with Frameworks and Libraries     117
Spring     118
JSF     119
WebWork/Struts 2     119
Struts "Classic"     120
Beehive     121
Hibernate     122
Something Old, Something New: Annotations      122
Summary     125
The Projects
InstaMail: An Ajax-Based Webmail Client     129
Application Requirements and Goals     129
Dissecting InstaMail     130
Configuration Files     132
The Client-Side Code     134
The Server-Side Code     163
Suggested Exercises     187
Summary     188
Share Your Knowledge: DWiki, the DWR-Based Wiki     189
Application Requirements and Goals     189
FreeMarker     191
Apache Derby     194
Spring JDBC     195
Dissecting DWiki     197
Configuration Files     199
The Client-Side Code     205
The Server-Side Code     230
Suggested Exercises     257
Summary     258
Remotely Managing Your Files: DWR File Manager     259
Application Requirements and Goals     259
dhtmlx UI Components     261
Jakarta Commons IO     268
Jakarta Commons FileUpload     269
Dissecting Fileman     270
Configuration Files     273
The Client-Side Code     278
The Server-Side Code      314
Suggested Exercises     326
Summary     326
Enter the Enterprise: A DWR-Based Report Portal     329
Application Requirements and Goals     329
Spring Dependency Injection (IoC)     331
DataVision     333
Quartz     336     337
A Sample Database to Report Against     340
Dissecting RePortal     341
Configuration Files     346
The RePortal Database     351
The Client-Side Code     352
The Server-Side Code     385
Suggested Exercises     416
Summary     417
DWR for Fun and Profit (a DWR Game!)     419
Application Requirements and Goals     419
DWR Annotations     420
Reverse Ajax in Action     421
Anything Else, or Can We Get Goin' Already?!?     422
Dissecting InMemoria     423
Configuration Files     424
The Client-Side Code     426
The Server-Side Code     441
Suggested Exercises     456
Summary     456
Timekeeper: DWR Even Makes Project Management Fun!     457
Application Requirements and Goals      457
HSQLDB     458
Hibernate     459
Ext JS     461
Dissecting Timekeeper     463
Configuration Files     465
The Client-Side Code     471
The Server-Side Code     507
Suggested Exercises     520
Summary     521
Index     523
Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)