Friday Apr 11, 2014

Non-blocking I/Os in Servlet 3.1

With the advent of platforms and frameworks such as Node.js, Vert.x, ... and more generally the rise of the Event-driven programming paradigm, asynchronous non-blocking I/Os are becoming more and more important in today's web applications.

Prior to Servlet 3.0, Servlet were synchronous. Servlet 3.0 (part of Java EE 6) added support for asynchronous request processing but only with ‘traditional’ I/Os (i.e. blocking I/Os) but this approach can sometime limit the scalability of an application.

The support for non-blocking I/Os has been added for Asynchronous Servlet in Servlet 3.1 (JSR 340 - part of Java EE 7). The net result is that the number of connections that can simultaneously be handled by the Servlet Container is greatly increased. This improves the resources utilization and the overall Web Container scalability.

It should be mentioned that other features haven added to the Servlet 3.1 such as support for the HTTP 1.1 Upgrade Mechanism. This new capability is used, for example, by the WebSocket API (JSR 356) to upgrade an existing HTTP connection to a TCP based WebSocket connection. In Servlet 3.1, the HTTP Upgrade Mechanism can also use non-blocking I/Os.

This article and this JavaOne session explains how asynchronous non-blocking I/Os in Servlet 3.1 The JavaOne session also covers the HTTP Upgrade mechanism and the other additions to the Servlet 3.1 API (various security enhancements and other miscellaneous features).

Thursday Jul 25, 2013

role-name="*" and role-name="**" in Servlet 3.1

Servlet 3.1 is a relatively minor release included in Java EE 7. However, the Java EE foundational API still contains some very important changes. One such set of features are the security enhancements done in Servlet 3.1 such as the new role-name="*" and role-name="**" options. Servlet 3.1 co-spec lead Shing Wai Chan outlines the use case for the feature and shows you how to use it in a recent code example driven post. He also references the features in his brief Servlet 3.1 overview presentation on the GlassFish Videos YouTube channel (embedded below).

You can also check out the official specification yourself or try things out with the newly released Java EE 7 SDK.

Tuesday Jul 03, 2012

Servlet 3.1 Early Draft Now Available

JSR 340 has released an Early Draft of the Servlet 3.1 specification.

Other than the usual clarifications and javadoc updates, ProtocolHandler and WebConnection are new classes that encapsulates the protocol upgrade processing. This will typically be used for upgrading an HTTP connection to a WebSocket. Section in the specification provide more details on it.

Servlet 3.1 Early Draft

Section 3.7 explain non-blocking request processing by the Web container. ReadListener and WriteListener are new interfaces that represents a call-back mechanism to read and write data without blocking.

As with other Java EE 7 specifications, progress can be tracked at The Expert Group discussions are archived and you can participate by sending an email to