如何获取websocket端点内的cookie值 [英] How can I get a cookie value inside websocket end-point

查看:2627
本文介绍了如何获取websocket端点内的cookie值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用基于JavaEE 7的Websocket-API。

I'm using Websocket-API based on JavaEE 7, in my application.

我需要访问websocket端点内的cookie中设置的值 [注释一个:@ServerEndpoint(/ websocket)] 。我会怎么做?

I'm required to access the values set in cookies inside my websocket endpoint [Annotated one : @ServerEndpoint ("/websocket") ]. How would I do that?

@onOpen()方法存在,到这个websocket端点被建立。

@onOpen() method is there, which will be called automatically when a connection to this websocket endpoint is established. I want to access cookies values in there, inside this method.

我知道如何在servlet或JSP中这样做,但我是WebSocket的新手。

I know how to do that in a servlet or JSP, but I'm new to Websockets.

请帮我做这个。提前感谢。

Please help me doing this. Thanks in advance.

推荐答案

通过 @ServerEndpoint(configurator = MyConfigurator)访问请求参数。

Access to request parameters is done via the @ServerEndpoint(configurator=MyConfigurator.class) technique.

请参阅,因为它的技术非常相似。

See other answer on how to access the HttpSession, as its techniques are very similar.

这篇关于如何获取websocket端点内的cookie值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆