Member-only story
Beware of Servlet 4.0 and above
Servlet API is the most fundamental and enabling of the Java technologies used in Java Web applications. Any ordinary Java web application depends on Servlet API for handling HTTP requests and sessions. Prevailing today libraries such as Spring MVC or implementations of JAX-RS are built on top of Servlet API.
Servlet API is so convenient and to the point that not many changes have occurred in Servlet API since the excellent version 3.1 was released in 2013. In the latest released Servlet 5.0, the only improvement was a new name for familiar javax
package — jakarta
. In Servlet 4.0 released five years ago included a more important enhancement — support for HTTP/2 protocol.
Theoretically, HTTP/2 should be more performant than its predecessor HTTP/1.1. But compared to its predecessor, HTTP/2 is far more complex and more complicated to debug. In practice performance of HTTP/2, like performance of any good idea, largely depends on its implementation.
With Java HTTP2 is not faster than HTTP/1.1
It is easy to demonstrate that HTTP/2 is faster than HTTP/1.1. In a JavaScript-based Node.js server, HTTP2 reduces time of network requests by 20%. The difference seems small, but it is consistent.