The <jsp:include> standard action at first request
With the include standard action, there’s less work at translation time, and more work with each request, especially if the included file is a JSP.
The client makes a request for Contact.jsp, which has not been translated. The Container reads the Contact.jsp page to start the translation process.
The container sees the include standard action, and uses that to insert a method call in the generated servlet code that—at runtime—will dynamically combine the response from Header.jsp into the response from Contact.jsp. The Container generates servlets for both JSP files. (This is not dictated by the spec, so we’re showing only an example of how it could work.)
The Container compiles the translated source file into a servlet class. It’s just like any other servlet at this point. The generated servlet class file is loaded into the Container’s JVM and is initialized. Next, the Container allocates a thread for the request and calls the JSP’s _jspService() method.
The Contact servlet hits the method that does the dynamic include, and something vendor-specific happens! All we care about is that the response generated by the Header servlet is combined ...
Get Head First Servlets and JSP, 2nd Edition 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.