JSPs are based on Servlets technology. They are Web pages, written in a hybrid of HTML and the JSP scripting syntax. The JSP content is marked as such by special operators such as <% %>, <%! %> and <%= %>. Inside these elements is ordinary Java code. The Web server processes this content when the page is requested, executing the scripts, evaluating expressions, and so forth, typically resulting in the generation of proper HTML to take the place of the JSP elements. The client never sees the JSP content, only the finished HTML page.
JSPs are actually compiled into servlets the first time they are requested from the Web server. The resulting servlet is a sort of inverse of the JSP in that now it's the Java code that's native — copied verbatim from the JSP elements — and the HTML has to be "escaped" in a sort of "print statement" as it's encountered.
So a Java Web application can be composed of JSPs, raw servlets, or both.
Copyright © 2002 by William W. Provost