1.2 JavaServer Pages JSP is an extremely powerful choice for Web development. JSP is a technology using
server-side scripting that is actually translated into Servlets and compiled before they
are run. This gives developers a scripting interface to create powerful Java Servlets.
JSP pages provide tags that allow developers to perform most dynamic content
operations without writing complex Java code. Advanced developers can add the full
power of the Java programming language to perform advanced operations in JSP
Template Pages Clearly, the most effective way to make a page respond dynamically would be to
simply modify the static page. Ideally, special sections to the page could be added that
would be changed dynamically by the server. In this case pages become more like a
page template for the server to process before sending. These are no longer normal
Web pages—they are now server pages.
On a server page, the client requests a Web page, the server replaces some sections of
a template with new data, and sends this newly modified page to the client (See
Figure 1-3. Server Page Since the processing occurs on the server, the client receives what appears to be static
data. As far as the client is concerned there is no difference between a server page and
a standard Web page. This creates a solution for dynamic pages that does not consume
client resources and is completely browser neutral.
Static Data vs. Dynamic Elements Since JSP pages are designed around static pages, they can be composed of the same
kind of static data as a standard Web page. JSP pages use HTML or XML to build the
format and layout of the page. As long as a normal Web page could contain the data,
so can the JSP page.
In order to replace sections of a page, the server needs to be able to recognize the
sections it needs to change. A JSP page usually has a special set of "tags" to identify a
portion of the page that should be modified by the server. JSP uses the
tag to note
the start of a JSP section, and the
tag to note the end of a JSP section. JSP will
interpret anything within these tags as a special section.
JSP pages usually contain a mixture of both static data and dynamic elements. It is
important to understand the distinction between the two forms. Static data is never
changed in the server page, and dynamic elements will always be interpreted and
replaced before reaching the client.