Since Subbu wrote BigPipe using node.js, I had to see how the same thing would look like in a Java async servlet.
Stephan Schmidt had already written Facebook BigPipe for Java, but using a synchronous servlet model, not asynchronous. I decided to implement it using Jetty continuations and the Jetty HTTP client, but the code should be easy to adapt to servlet 3.0 AsyncContext.
The code initially constructs the page with a few empty divs that will contain the pagelets, for example:
<div id='pagelet3'></div>
I keep the connection open from the browser to the server while I render pagelets.…