SSE (Server-Sent Events) enables the server to push updates to the browser. It's simpler than WebSocket and perfect for many use cases.
When to Use SSE
- Dashboards with live data
- Notification systems
- Progress updates
- Live feeds
SSE vs WebSocket
SSE: Server pushes, client uses HTTP for actions
WebSocket: Full bidirectional, persistent connection
Implementation
@Page(value = "/notifications", communication = Communication.SSE)
public class NotificationsPage extends HtmlPage
{
public void pushNotification(String message)
{
notificationArea.addElement(createNotification(message));
// Changes automatically pushed via SSE
}
}
Conclusion
SSE is the sweet spot for server push—simpler than WebSocket, works with standard HTTP infrastructure.