Java Magazine, Nov/Dec 2017
ORACLE COM JAVAMAGAZINE NOVEMBER DECEMBER 2017 19 java ee 8 this does not mean that your JSP web applications are doomed to HTTP 11 slowness there is a solution albeit a bespoke solution You know that JSP pages are translated The runtime discovery of the URL mapping that causes a servlet to be activated has been refined thanks to the new Servlet Mapping API into servlets and requests to those servlets can be intercepted with web filters With this knowledge you can create a solution that allows you to harness the power of Server Push By implementing a web filter all requests to the web application can be intercepted and the intercepting filter maintains a cache of resource locations for each page requested On subsequent requests the resources the page requires are pulled from the cache and pushed to the client before the filter forwards to the JSP translated servlet or to the next filter in the chain The way this works is that the first time a page is requested the resources it needs are identified It is assumed that soon after the initial page request is made the browser will start asking for the resources it needs These resource requests are identified by examining the referrer header and matching the referrer page name to the name of the initial page request thus building up a cache of page to resource locations This is an efective solution that brings the Server Push feature to any part of your application that does not support it out of the box In fact this is the solution that Jetty version 9 has implemented in its PushCacheFilter web filter The HttpServletRequest is the gateway to the Server Push filter which means that anywhere you find the HttpServletRequest instance you can use a new instance of PushBuilder and start pushing resources Runtime Discovery of Mappings The runtime discovery of the URL mapping that causes a servlet to be activated has been refined thanks to the new Servlet Mapping API Frameworks that need to know the exact mapping that caused the servlet activation are the most likely to benefit from this feature For
You must have JavaScript enabled to view digital editions.