Java EE 7 SDK 

Samples Main Page

The Draw WebSocket Sample Application

This sample application consists of a drawing board shared among several users with real-time change propagation.

Description

This sample demonstrates the main advantage of the Java API for WebSocket (JSR 356) compared to other technologies based on the HTTP protocol: bi-directional real-time communication. When you deploy this application and load its front page, the changes you make to the canvas are propagated to all connected clients. The whole state is not propagated: if the first users draws a smiley face and the second user joins right after, this second user only sees a bank canvas. But when the second user starts drawing something, the first user sees it immediately.

Key Features

This sample application demonstrates the following key features:

Building, Deploying, and Running the Application

Perform the following steps to build, deploy, and run the application:

  1. Set up your build environment and configure the application server with which the build system has to work by following the common build instructions.
  2. app_dir is the sample application base directory: samples_install_dir/javaee7/websocket/draw.
  3. Build, deploy, and run the sample application using the run outcome.

    mvn clean verify cargo:run

  4. The front page of this sample is at http://localhost:8080/websocket-draw.
    (The port number might vary.)
  5. Use the clean outcome to undeploy the sample application and to remove the temporary directories such as build and dist.

    mvn clean

Troubleshooting

If you have problems when running the application, refer to the troubleshooting document.



Copyright © 1997-2013 Oracle and/or its affiliates. All rights reserved.