JSP Processing
A JSP page cannot be sent as-is to the browser; all JSP elements must first be processed by the server. This is done by turning the JSP page into a servlet, and then executing the servlet.
Just as a web server needs a servlet container to provide an interface to servlets, the server needs a JSP container to process JSP pages. The JSP container is often implemented as a servlet configured to handle all requests for JSP pages. In fact, these two containers—a servlet container and a JSP container—are often combined into one package under the name web container (as it is referred to in the J2EE documentation).
A JSP container is responsible for converting the JSP page into a servlet (known as the JSP page implementation class ) and compiling the servlet. These two steps form the translation phase . The JSP container automatically initiates the translation phase for a page when the first request for the page is received. The translation phase takes a bit of time, of course, so a user notices a slight delay the first time a JSP page is requested. The translation phase can also be initiated explicitly; this is referred to as precompilation of a JSP page. Precompiling a JSP page avoids hitting the user with this delay, and is discussed in more detail in Chapter 12.
The JSP container is also responsible for invoking the JSP page implementation class to process each request and generate the response. This is called the request processing phase. The two phases are illustrated ...
Get Java Server Pages 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.