Search code examples
javascriptjavawebsocketsession-variablesjsr356

session variables on jsr 356 and HTML/js client based


I have been checking on the internet for a while and couldn't find an answer to my query...

I am building a web app using java in the server side and plain HTML/javascript on the client side.

My idea is to implement websockets using JSR 356 and need to keep some data (user login details) persistent during the whole session.

QUESTION: Is there a way to How can I keep data persistent during the whole session so I don't need to send it again on each call (something similar to jsp/servlet EL)?

e.g.

${sessionScope["userId"]}

thanks


Solution

  • I ended up adding the userId to the URL on the websocket so each session is linked to the user while the client stores the userId in the localStore to keep track of it.