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 responsible for intercepting JSP page requests. To process all JSP elements on the page, the container first converts the JSP page to a servlet (known as the JSP page implementation class). The conversion is quite straightforward; All template text is converted to print ln () statements similar to those of the hand coded servlet shown in Example 3-1, and all JSP elements are converted to Java code that implements the corresponding dynamic behavior. The container then compiles the servlet class.
Converting the JSP page to a servlet and compiling the servlet form the translation phase. The JSP container automatically starts the translation phase of a page when it receives the first request of the page. Since the translation phase takes a while, the first user requesting a JSP page notices a slight delay. The translation phase can also be initiated explicitly; This is known as precompiling a JSP page. Precompiling a JSP page is one way to avoid hitting the first user with this delay. This is discussed in more detail in Chapter 16.