There's more...

Server Push will only work under SSL. In other words, if you are using GlassFish 5 and try to run this recipe, your URL should be something like this:

https://localhost:8181/ch04-serverpush

If you miss it, the code will still work, but using HTTP/1.0. means that when the code asks for newPushBuilder, it will return null (not available):

if (pb != null) {   ...}

Get Java EE 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.