Example web app for Server Sent Events (SSE) and Websockets
posted 1 month ago
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).
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.