| Java EE 7 SDK |
This sample is a Hello world application using the Java API for WebSocket.
This sample shows how to use the annotations in the Java API for WebSocket (JSR 356) to create a simple
WebSocket endpoint. The class EchoEndpoint is a very simple endpoint: it sends back every incoming text message. You can access the endpoint
from the index.html page included in this sample. This page contains a very simple JavaScript client that sends the contents of
a text field to the server and shows the response on the page.
This sample demonstrates the following key features:
Creating a simple WebSocket endpoint using the following annotations:
@ServerEndpoint@OnMessagePerform the following steps to build, deploy, and run the application:
app_dir is the sample application base directory: samples_install_dir/javaee7/websocket/echo.run outcome.
mvn clean verify cargo:run
http://localhost:8080/websocket-echo. clean outcome to undeploy the sample application and to remove the temporary directories such as build and dist.
mvn clean
If you have problems when running the application, refer to the troubleshooting document.
Copyright © 1997-2013 Oracle and/or its affiliates. All rights reserved.