Tuesday Nov 18, 2014

JavaOne Replay: "Into the Wild with Servlet Async IO"

Greg Wilkins has an impressive 'Web pedigree’; he is the founder and lead developer of Jetty.  Greg is a long-time member of the Servlet Expert Group; he is also a member of the IETF HTTP/2 working group member, etc.!

During his JavaOne session, Greg gave a deep technical overview on Asynchronous IO using the Servlet API.  Greg starts by explaining what asynchronous means in the context of a Servlet. He then goes and explains the Servlet 3.0 asynchronicity support.  The rest of the talk is then spent on the Servlet 3.1 API and how to write effective asynchronous servlets (and how the inner-working of the API).  Greg also shares some of the motivations behind the Servlet 3.1 API and the technical choices behind it. Not only that, Greg is also talking about some 'potential more obvious technical options' and why those options were not selected at the end.

This technical session provides different angles (e.g. Servlet API explanations, some deep technical points such as some of the Jetty implementation details but also best practices advices, etc.).  Overall this session is highly recommended for anyone who want to understand asynchronicity in the context of the Servlet API.


You can find Greg's slides here.

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 2.3.3.5 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 servlet-spec.java.net. The Expert Group discussions are archived and you can participate by sending an email to users@servlet-spec.java.net.