Java Reference
In-Depth Information
<script type="text/javascript">
function acmeChatRelay()
if ("WebSocket" in window)
alert("WebSocket is supported by your Browser!");
// Let us open a web socket
var ws = new WebSocket("ws://localhost:8080/IntroToEE7/acmechat");
ws.onopen = function()
// Web Socket is connected, send data using send()
ws.send("Message to send");
alert("Message is sent...");
ws.onmessage = function(evt)
var received_msg =;
alert("Message from server: " + received_msg);
ws.onclose = function()
// websocket is closed.
alert("Connection is closed...");
// The browser doesn't support WebSocket
alert("WebSocket NOT supported by your Browser!");
The following excerpt is taken from web/chapter09/acmeChatClient.xhtml , and it demonstrates how to invoke
the WebSocket call.
<ui:composition template="../layout/custom_template.xhtml">
<ui:define name="content">
Welcome to the Acme Chat Client. Use the
<h:inputTextarea id="messageText" cols="30" rows="10"/>
Search WWH ::

Custom Search