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!

One thought on “How to get the HttpSession object from a ServerEndpoint in Java EE 7

  1. Anom

    Hi,
    Have any idea how we can get the httpsession if a websocket endpoint class is singleton ?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *