• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Example web app for Server Sent Events (SSE) and Websockets

 
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now that JAX-RS 2.1 has been finalized, its reference implementation Jersey supports its new features, including Server Sent Events. To get folks going with that, here is a minimal web app that shows SEE in action. Drop it in your favorite servlet container's webapps directory, and it should become available automatically, probably at an URL like http://localhost:8080/websocket/. It's been tested with Tomcat 8.5 on Java 8 (which is the minimum Java version supported for JAX-RS 2.1).

The web app is based on this earlier one that demonstrated websockets, and also includes that part (hence its name).

One pitfall to avoid: the example in the documentation makes it seem as if the name of the message ("message-to-client") can contain hyphens - that does not work with current browsers. But that example code has in any case not been updated to the released version, so you're better off just using the source code that comes with this web app.
Filename: websocket.war
File size: 4 megabytes
 
Just let me do the talking. Ahem ... so ... you see ... we have this tiny ad...
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic