title: Websocket - httpSession returns null
body: <p>I would like to make the connection between a websocket handshake \ session to a HttpSession object.</p>
  
  <p>I've used the following handshake modification:</p>
  
  <pre><code>public class GetHttpSessionConfigurator extends ServerEndpointConfig.Configurator
  {
  @Override
  public void modifyHandshake(ServerEndpointConfig config, 
                              HandshakeRequest request, 
                              HandshakeResponse response)
  {
      HttpSession httpSession = (HttpSession)request.getHttpSession();
      config.getUserProperties().put(HttpSession.class.getName(),httpSession);
  }
  }
  </code></pre>
  
  <p>As mentioned in this post:
  <a href="https://stackoverflow.com/questions/17936440/accessing-httpsession-from-httpservletrequest-in-a-web-socket-socketendpoint">Accessing HttpSession from HttpServletRequest in a Web Socket @ServerEndpoint</a></p>
  
  <p>Now,
  For some reason on the hand shake, the (HttpSession)request.getHttpSession() returns null all the time.</p>
  
  <p>here is my client side code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Testing websockets&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div&gt;
      &lt;input type="submit" value="Start" onclick="start()" /&gt;
  &lt;/div&gt;
  &lt;div id="messages"&gt;&lt;/div&gt;
  &lt;script type="text/javascript"&gt;
      var webSocket = 
          new WebSocket('ws://localhost:8080/com-byteslounge-websockets/websocket');
  
      webSocket.onerror = function(event) {
          onError(event)
      };
  
      webSocket.onopen = function(event) {
          onOpen(event)
      };
  
      webSocket.onmessage = function(event) {
          onMessage(event)
      };
  
      function onMessage(event) {
          document.getElementById('messages').innerHTML 
              += '&lt;br /&gt;' + event.data;
      }
  
      function onOpen(event) {
          document.getElementById('messages').innerHTML 
              = 'Connection established';
      }
  
      function onError(event) {
          alert(event.data);
      }
  
      function start() {
          webSocket.send('hello');
          return false;
      }
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Any ideas why no session is created ?
  Thanks</p>