Member-only story
Fantastic enhancements in the Servlet API 6.0
Novel features of the omnipresent Servlet API. Why developers hurry to migrate to Servlet API 6.0.
Servlet API— enables all Java web applications
The Servlet API so perfect that in Java no one could propose anything better and it hard to imagine how to improve it. Spring added a layer above it, but still even in a Spring Boot application is might be easier to use a Servlet
instead of a @Controller
. And if you need a filter, in Spring the easiest option is to use directly the HttpFilter
provided by the Servlet API.
Before Servlet API 6.0 was released in 2022, little has changed since Servlet 3.1 released in 2013. The most useful modern features that every developer could benefit from were concise web listeners and HttpFilter
. With Servlet 3.1 it was annoying to cast legacy types ServletRequest
and ServletResponse
to HttpServletRequest
and HttpServletResponse
and having to implement unneed methods of the interfaces.
In this post I compare the source code of the Servlet API 6.0 and 5.0. To illustrate the post I deployed to the Google App Engine a Spring Boot-based application using all the novel methods introduced in the the Servlet API 6.0.