Chapter 4. WebSocket on Tomcat


4.1. About WebSocket

WebSocket is a web technology that provides bi-directional, full duplex, messages to be instantly distributed between the client and server over a single TCP socket connection. A full duplex communication allows two-way communication simultaneously.
The container provides an implementations of the WebSockets 1.0 JSR 356 API. To use the API, you must run Java 7+ and configure the APR or NIO2 HTTP/1.1 connectors of the web container.
JSR 356 is a standard for WebSocket API for Java. Developers can use the JSR 356 API for creating WebSocket applications independent of the implementation. The WebSocket API is purely event driven.
Developers can use the JSR 356 Java API for WebSocket to integrate WebSockets in applications on the server side as well as on the Java client side. Tomcat 7 and 8 implement the WebSocket protocol which adheres to JSR-356 standard.
A Java client uses JSR 356-compliant client implementation to connect to a WebSocket server. For web clients, WebSocket JavaScript API can be used to communicate with WebSocket server. The only difference between a WebSocket client and a WebSocket server is the method in which they are connected. A WebSocket client is a WebSocket point from which the connection to a peer originates. A WebSocket server is WebSocket endpoint which is already published and awaits connections from peers.
Some examples where WebSocket can be used include banking, chat, multiplayer, and social networking applications.
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat, Inc.