Using Server Push to make objects available beforehand
One of the most important new features of Servlet 4.0 is the HTTP/2.0 support. It brings another cool and reliable feature—the Server Push.
This recipe will show you how to use Server Push in a filter and push the resources needed in every request that we want.
Getting ready
We should first add the dependencies needed:
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>4.0.0-b07</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>7.0</version> <scope>provided</scope> </dependency>
How to do it...
- We first create
UserServlet
that callsuser.jsp
:
@WebServlet(name = "UserServlet...