This example implements a simple chat client and server. Using
server-initiated updates, you can easily push events from one
user to other users. Server-initiated updates are implemented
using Ajax long polling.
When deploying in a Servlet-3.0 container, you can enable its
asynchronous processing and JWt will benefit from this to not tie up
threads for each open connection. But you can also deploy the
application on a Servlet-2.5 container, reverting to blocking
threads. This may be convenient when a Servlet-3.0 container is not
available, e.g. during development.
It also illustrates nice benefits of a class-based approach to web
application development: you can easily instantiate the same widget
class multiple times. The SimpleChatClient widget may be reused
just as you reuse basic JWt widgets such as a push button.
Interactive applications like these, which allow users to post HTML
text to other users, are notorious for cross-site-scripting (XSS)
attacks: a user enters malicious (javascript) code as part of
his message. When another user renders this message, it may transmit
unwanted private information retrieved from, for example, browser
cookies. JWt prevents such attacks completely, and without any
responsibility to the developer, since widgets such as WText ensure
that what is displayed is only passive text, discarding anything
that is not strictly text.