Example of creating an HttpSession for a websocket when it is the initial connection:
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);
}
}
and indeed this "restores" what I had assumed was the default behavoiur,
including setting the browser cookie
JSESSIONID in the response of a
websocket with no existing session, creating a new HttpSession, calling
sessionCreated() etc
so, problem solved