On Sun, Oct 27, 2013 at 4:46 PM, Neil Martin <nsm...@gmail.com> wrote:
> Thanks for the replies Mark. > > It does seem to me that most developers using websockets under tomcat are > going to want that integration with the J2EE container. Maybe I'm wrong, > but it seems like the plumbing to make the servlet context available to the > EndpoingConfig will be messy because the websockets framework has been > designed to be divorced from its environment. > > From this perspective, the tomcat 7 websockets implementation seems easier > to work with; at least for developers who are looking to use websocket > endpoints as a replacement for servlets. Does this make sense? > Perhaps, such request can be posted on EG mail list [1] or JIRA issue tracker [2] [1] jsr356-expe...@websocket-spec.java.net [2] http://java.net/jira/browse/WEBSOCKET_SPEC > > Neil > > Sent from my iPad > > > On Oct 27, 2013, at 8:04, Mark Thomas <ma...@apache.org> wrote: > > > > On 27/10/2013 12:36, Johan Compagner wrote: > >>>> and i have a follow up question about this, with a servlet or a filter > >>> you > >>>> can do: getServletContext() then you have access to the resources of > the > >>>> web application and stuff like that > >>>> How is that possible in an websocket endpoint? > >>> > >>> The ServerEndpointConfig will have the modifyHandshake() method called > >>> where you have access to elements of the request and response. You need > >>> to copy any data you need at this point. > >> > >> i was not talking about (http)request or response objects. > >> But purely the ServletContext to access stuff of the web app itself. > > > > You'd have to put the ServletContext into the EndpointConfig. > > > >>>> If i want to load in a file that is in the current webapps WEB-INF dir > >>> how > >>>> do i do that? How do i get an url or inputstream (getResource() call) > to > >>>> that file? > >>> > >>> Calls via the class loader will continue to work. > >> It's not a resource in the WEB-INF/classes or a resource in a jar file > >> I am talking about a normal resource anywhere in a war file itself > (thats > >> not in jars/classes) > >> So for example i just want to get the content of the index.html in the > root > >> of the myapp.war > >> Or i want a special properties file that i have in the > >> myapp.war/WEB-INF/my.properties > >> > >> > >> in a filter or servlet: > >> > >> getServletContext().getResource("WEB-INF/my.properties"); > >> > >> what is the line of code in a web socket endpoint to do the same? > >> It seems that it is impossible to get the context of the webapp the > socket > >> is in.. > > > > It isn't exposed via the API because WebSockets were designed to > > be implementable independently from a J2EE container. You can do it via > > the EndpointConfig but you have to do your own plumbing. > > > > Mark > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > > For additional commands, e-mail: users-h...@tomcat.apache.org > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >