Skip to content

Commit 62db91e

Browse files
Alex Vargaszhendrikse
authored andcommitted
Bael 389 - Building URL dynamically between host and pathname (eugenp#1323)
* Project for " A Guide to the Java API for WebSocket" article * Setting dependencies correctly * Formatting adjustments * Removing tomcat7 maven plugin * Applying formatt - No spaces * BAEL-389 - Building URL dynamically between host and pathname
1 parent 250cb7c commit 62db91e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

java-websocket/src/main/webapp/websocket.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ var ws;
22

33
function connect() {
44
var username = document.getElementById("username").value;
5-
ws = new WebSocket("ws://" + document.location.host + "/java-websocket/chat/" + username);
6-
5+
6+
var host = document.location.host;
7+
var pathname = document.location.pathname;
8+
9+
ws = new WebSocket("ws://" +host + pathname + "chat/" + username);
710

811
ws.onmessage = function(event) {
912
var log = document.getElementById("log");

0 commit comments

Comments
 (0)