Java - Does javax.websocket.Session and javax.servlet.http.HttpSession use the same JSESSIONID?

时间:2015-11-12 12:07:38

标签: java http session websocket jsessionid

I would like to know if getId() method from javax.websocket.Session and getId() method from javax.servlet.http.HttpSession always share the same JSESSIONID.

NB: I know that those two methods are implementation dependent, and I didn't find a link between those two session id on the internet/documentation.

Goal: A client connects to my website (a JSESSIONID is created) and is authentified by a login/password (client object is linked to the JSESSIONID), then he uses website's chat ... will he be recognized by his session id from the websocket ?

=> If the anwser is "no, it's not always the same", could you propose an alternative solution ? Thanks

1 个答案:

答案 0 :(得分:1)

websocket Session和HttpSession的ID不相关。

一个简单的原因是与服务器端HttpSession关联的客户端可以有多个websocket会话,这些会话都需要一个自己唯一的ID。