Servlets 如何从BayeuxServer.SessionListener内部访问ServletContext?

Servlets 如何从BayeuxServer.SessionListener内部访问ServletContext?,servlets,cometd,Servlets,Cometd,是否可以从BayeuxServer.SessionListener回调函数内部访问ServletContext?我有一个对象,我一直将其作为ServletContext的属性提供。我可以将其设置为单例,但我想知道。您不能直接访问ServletContext,但可以通过以下方式访问其属性: BayeuxServer BayeuxServer=。。。; BayeuxContext BayeuxContext=bayeuxServer.getContext(); 对象attributeValue=ba

是否可以从BayeuxServer.SessionListener回调函数内部访问ServletContext?我有一个对象,我一直将其作为ServletContext的属性提供。我可以将其设置为单例,但我想知道。

您不能直接访问
ServletContext
,但可以通过以下方式访问其属性:

BayeuxServer BayeuxServer=。。。;
BayeuxContext BayeuxContext=bayeuxServer.getContext();
对象attributeValue=bayeuxContext.getContextAttribute(attributeName);

很抱歉,我说的太多了,但是如何获取BayeuxServer?