tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niki Dokovski <nick...@gmail.com>
Subject Re: Accessing ServletContext from WebSocket endpoint
Date Sat, 07 Dec 2013 07:25:37 GMT
On Sat, Dec 7, 2013 at 5:48 AM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> Johan,
>
> On 12/6/13, 3:53 AM, Johan Compagner wrote:
> > I ask the same question yes, but i still don't see a way to really
> > do that nicely through an EndpointConfig
>
> EndpointConfig.getUserProperties().put("ServletContext",
>  ((HttpSession)request.getHttpSession()).getServletContext());
>
> ??
>
> It's ugly, but, as someone said, it does require that you do your own
> plumbing. There may be a cleaner way to get the servlet context e.g.
> not having to create an HttpSession. It seems clear that
> HandshareRequest ought to have a getServletContext method as well as a
> getSession method.
>
> > So if somebody has a nice example that gets the Servletcontext that
> > i then can access in the websocket instance that would be nice This
> > example should be something different then what is given here:
> >
> http://stackoverflow.com/questions/17936440/accessing-httpsession-from-httpservletrequest-in-a-web-socket-socketendpoint
> >
> >  because i only see currently api to get the HttpSession and then
> > through that the ServletContext, problem is that there is no http
> > session..
>
> Aah... if there is no session, getHttpSession doesn't automatically
> create one(). Boo.
>
> Clearly this is an opportunity for the EG to step in and correct an
> oversight.
>

Fully agree with Chis. Making jsr 356 a "generic" clearly does not meet
current needs and use cases to the extend it should. Looking forward to
Java API WebSocket 2.0
I guess logging feedback on JSR jira [1] will help improving the next
release...

[1] https://java.net/jira/browse/WEBSOCKET_SPEC

>
> -chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message