Just another blog about computers and programming.

How to get the HttpSession object from a ServerEndpoint in Java EE 7

All things web-related in a Java EE container is most likely exposed using a Servlet. The Java EE 7 WebSocket server endpoints are no different. Should one therefore not be able to get hold of the HttpSession object from within a ServerEndpoint class?

Yes it is doable. I exemplified a solution in code as a posted answer over at stackoverflow.com. Enjoy!