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.

  1. 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.

    image with no caption
  2. 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.)

    image with no caption
  3. 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.

    image with no caption
  4. 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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.