Note that there are some explanatory texts on larger screens.

plurals
  1. POHtml5 websocket implementation for a java application that can interact with database
    primarykey
    data
    text
    <p>I am working on an application that requires a lot of user interaction. Its kind of a discussion form where people can comment. Currently we are using web services and every time user post a comment or a reply to a comment we are calling a webservice and it is communicating with database and doing the rest of the things. I found this process rather slow. So i read in few places that web sockets may be solution to my problem where I can directly use available apis to commiunicate with database and make my application faster. I searched a lot, in some examples available online they were using servlets too and in some they were not. It was very confusing. I just want to use html5 websockets. the UI code is a page which will send some text to backend. The JS code is: </p> <pre><code>&lt;script&gt; var connection; function connect() { console.log("connection"); connection = new WebSocket("not sure what exactly to use here"); // Log errors connection.onerror = function (error) { console.log('WebSocket Error '); console.log(error); }; // Log messages from the server connection.onmessage = function (e) { console.log('Server: ' + e.data); alert("Server said: " + e.data); }; connection.onopen = function (e) { console.log("Connection open..."); } connection.onclose = function (e) { console.log("Connection closed..."); } } function sayHello() { connection.send(document.getElementById("msg").value); } function close() { console.log("Closing..."); connection.close(); } &lt;/script&gt; </code></pre> <p>while creating new WebSocket object what path exactly i need to mention. Should I use servlets or not. Please give ideas about the backend java code. Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload