mixing web socket and regular http servlet

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

mixing web socket and regular http servlet

Bruno Konik

Hello all,

 

I would like to know if this is possible to register an http servlet (HttpServlet) and web socket servlet (WebSocketServlet) for the same path.

 

ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);

context.setContextPath("/");

context.addServlet(new ServletHolder(new MyWebSocketServlet()), “mypath”);

context.addServlet(new ServletHolder(new MyHttpServlet()), “mypath”);

 

Since the url to use the http servlet is http://server/mypath and the url to use websocket is “ws://server/mypath” (different scheme), I would imagine that this is possible but I can’t manage it.

 

Thanks for your help.

 

Bruno

 


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: mixing web socket and regular http servlet

Joakim Erdfelt-8
Your MyWebSocketServlet is a full blown HttpServlet.  Just implement doGet() and doPost() etc and you'll be golden.

On Fri, May 11, 2018, 12:24 PM Bruno Konik <[hidden email]> wrote:

Hello all,

 

I would like to know if this is possible to register an http servlet (HttpServlet) and web socket servlet (WebSocketServlet) for the same path.

 

ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);

context.setContextPath("/");

context.addServlet(new ServletHolder(new MyWebSocketServlet()), “mypath”);

context.addServlet(new ServletHolder(new MyHttpServlet()), “mypath”);

 

Since the url to use the http servlet is http://server/mypath and the url to use websocket is “ws://server/mypath” (different scheme), I would imagine that this is possible but I can’t manage it.

 

Thanks for your help.

 

Bruno

 

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: mixing web socket and regular http servlet

Bruno Konik

Ahhh yes of course !

 

Thanks a lot for your fast answer.

 

Bruno

 

De : [hidden email] [mailto:[hidden email]] De la part de Joakim Erdfelt
Envoyé : vendredi 11 mai 2018 18:44
À : JETTY user mailing list <[hidden email]>
Objet : Re: [jetty-users] mixing web socket and regular http servlet

 

Your MyWebSocketServlet is a full blown HttpServlet.  Just implement doGet() and doPost() etc and you'll be golden.

On Fri, May 11, 2018, 12:24 PM Bruno Konik <[hidden email]> wrote:

Hello all,

 

I would like to know if this is possible to register an http servlet (HttpServlet) and web socket servlet (WebSocketServlet) for the same path.

 

ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);

context.setContextPath("/");

context.addServlet(new ServletHolder(new MyWebSocketServlet()), “mypath”);

context.addServlet(new ServletHolder(new MyHttpServlet()), “mypath”);

 

Since the url to use the http servlet is http://server/mypath and the url to use websocket is “ws://server/mypath” (different scheme), I would imagine that this is possible but I can’t manage it.

 

Thanks for your help.

 

Bruno

 

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users