WebSockets
Traditionally, web applications have been developed using the request/response model followed by HTTP. In this traditional request/response model, the request is always initiated by the client, then the server sends a response back to the client.
There has never been any way for the server to send data to the client independently, that is, without having to wait for a request, until now. The WebSocket protocol allows full-duplex, two-way communication between the client (browser) and the server.
The Jakarta API for WebSocket allows us to develop WebSocket endpoints in Java.
In this chapter, we will cover the following topics:
- Developing WebSocket server endpoints
- Developing WebSocket clients in JavaScript
- Developing WebSocket clients in Java
Note
The source code for this chapter can be found on GitHub at https://github.com/PacktPublishing/Jakarta-EE-Application-Development/tree/main/ch09_src.