The Relationship Between JSP Pages and Java Servlets The simple mechanics of creating and using JSP pages masks the complexity of the under-the-covers activity.
JSP pages actually are compiled into Java servlets. Great hosting offer for jsp and serlvet hosting All those environment issues dealing with compiling and executing servlets come into play. Whereas you don't compile JSPs, your Java-enabled server performs the compilation from JSP page into a Java servlet for you.
Although you, the JSP developer, need not care about CLASSPATH and other settings, your server needs to know these settings. Your server needs access to the Java compiler and various classes required for servlet and JSP compilation.
The first time you request a JSP page, the server translates the page into a Java class.
Recall from the concept of J2EE containers. The JSP-enabled server has a JSP container that provides the environment necessary for this translation.
Sometimes, the JSP container is called the JSP engine; both terms are used interchangeably in this book. The server compiles the class generated by the JSP engine into a servlet. This servlet contains Java println statements that write the static text to the output stream, and Java code that implements the functionality of your JSP tags.
Depending on the amount of Java code generated by the JSP and the speed of the server, you may notice a slight delay during the JSP-to-servlet compilation.
However, subsequent requests of the JSP page do not cause a page retranslation and recompilation. The JSP request accesses the already compiled servlet in memory.
As an aside, some servers enable you to establish file aliases. You can avoid the delay caused by the first-time JSP translation and compilation by requesting your JSP page (causing translation and servlet generation), followed by creating an alias of your JSP page to the generated servlet.
Now, when your customer requests your JSP page, the server references the previously generated servlet, which is already compiled and in memory.