javascript – Java multi-client server and JS web

I have a web page with a chat in JS, the goal being that users can communicate with a server.

Currently, communication works without problems via a servlet, the problem occurs when there are multiple users because the server sends the same response to all when only one requests it.

The goal is for the server to interact with different users individually, holding conversations until the user decides to leave the page.

The server part is that you are developed in Java.