Server-sent events are part of the HTML 5 specification, which also includes WebSocket technology. Both communication models enable servers to send data to clients unsolicited. However, server-sent events establish one-way communication from server to clients, while a WebSocket connection provides a bidirectional, full-duplex communication channel between servers and clients, promoting user interaction through two-way communication. The following key differences exist between WebSocket and server-sent events technologies:
Server-sent events can only push data to the client, while WebSocket technology can both send and receive data from a client.
The simpler server-sent events communication model is better suited for server-only updates, while WebSocket technology requires additional programming for server-only updates.
Server-sent events are sent over standard HTTP and therefore do not require any special protocol or server implementation to work. WebSocket technology requires the server to understand the WebSocket protocol to successfully upgrade an HTTP connection to a WebSocket connection.
For more information about WebSocket technology, see Using the WebSocket Protocol in WebLogic Server in Developing Applications for Oracle WebLogic Server.
The WebLogic Server Server-Sent Events API is in the package
org.glassfish.jersey.media.sse. For information about the interfaces and classes included in this package, see the API documentation for
org.glassfish.jersey.media.sse in the Jersey 2.21 API Documentation.