JavaServer Pages
The first thing to understand about
JavaServer Pages is that
it’s a natural extension to the Java Servlet
technology. In fact, after some preprocessing by a translator, JSP
pages end up being nothing more than Java servlets. This is a point
that many beginning developers have a hard time understanding. JSP
pages are text documents that have a .jsp
extension and contain a combination of static HTML and
XML-like tags and
scriptlets. The tags and scriptlets encapsulate the logic that
generates the content for the pages. The .jsp
files are preprocessed and turned into .java
files. At this point, a Java compiler compiles the source and creates
a .class file that can be executed by a servlet
container.
The translator that turns the .jsp file into a
.java file takes care of the tedious work of
creating a Java servlet from the JSP page. Figure 1-2 illustrates how a JSP page is translated and
compiled into a servlet.

Figure 1-2. A JSP page is translated and compiled into a Java servlet
JSP technology has become an extremely popular solution for building web applications using the Java platform. JSP offers several advantages over its competitors:
JSP is a specification, not a product. Developers are able to choose a “best of breed” approach.
JSP pages are compiled, not interpreted, which can lead to better performance.
JSP pages support both scripting and access to the full ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access