Traditionally, web applications have been developed using the request/response model followed by the HTTP protocol. 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 a 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 fully duplex, two-way communication between the client (browser) and the server.
Java EE 7 introduced the Java API for WebSocket, which 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