Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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

 
Saloon Keeper
Posts: 5038
134
  • Mark post as helpful
  • send pies
  • 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
 
So I left, I came home, and I ate some pie. And then I read this tiny ad:
Download Free Java APIs to Work with Office Files and PDF
htttp://www.e-iceblue.com/free-apis.html
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!