Member-only story

How Servlet 4.0 and 5.0 are even more convenient than the perfect 3.1

Useful, potentially useful, not useful and harmful features of the modern Servlet API.

Marian C.
6 min readJan 30, 2022

Servlets — the foundation of Java web applications

Even if code of a typical web application does not contain many servlets, filters and listeners, all Java web applications are build on top of the Servlet API. In any Java web application HTTP requests are handled by servlets. More visible web technologies such as JAX-RS or Spring libraries MVC, Boot or Security are sometimes convenient but never indispensable addons to servlets. If you develop an application using Spring, it is smarter to stick to the oddities of the framework. But if you only have to customize an existing Spring application, it can be faster to do it with filters or listeners.

The recent servlet features are not equally useful

Servlet API is so perfect that it hardly changes over time. But there have been some important enhancements. The problem is that earlier overviews give misleading ratings of the latest, already 4 year-old, Servlet features — features that turned out to be harmful or practically useless were praised, whereas tiny but universally useful features were underrated or not mentioned. In this post I summarize and reevaluate all the features that appeared in Servlet 4.0.

The improvements that appeared in Servlet API 4.0 can be grouped into four categories:

  • Clearly and universally useful, even if tiny
  • Potentially or occasionally useful
  • Still not useful
  • Harmful

Differences between Servlet 4.0, 5.0 and 6.0

The only difference between Servlet 4.0 and 5.0 is the new name for javax package. In Servlet 5.0 javax was renamed jakarta. So one cannot say that 5.0 is better than 4.0. It is rather the opposite, if you upgrade an application from 3.1 to 5.0, you have to change all the imports. There is no sense whatsoever in migrating from 4.0 to 5.0.

--

--

Marian C.
Marian C.

Written by Marian C.

Java, JavaScript and SQL developer. Interested in data collection and visualization.

No responses yet

Write a response