Java Reference
In-Depth Information
Chapter 19
JSP:
Servlets Turned Inside Out
In our last chapter, the BudgetPro servlet example spent a lot of code generating
the HTML output for the servlet to send back to the browser. If you want to
change the HTML for any page (for example, add a background color), you
would have to modify the Java code (obviously)—but you're not really wanting
to modify the logic of the servlet, you only want to tweak its output. The
HTML that a servlet generates can be scattered among output statements, string
concatenations, classes, and method calls. Servlets, we might say, bury the
HTML deep inside the code. We're now going to take a look at JavaServer
Pages (JSP) which do the opposite—they expose the HTML and hide the code
down inside.
This technique has been given the fancy description, document-centric
server-side programs . They are “document-centric” because the HTML code is
so visible—JSP content looks like (and is) HTML with some additions. They
are “server-side” because all the work is done on the server and all the additions
and special features of JSP are boiled down to a simple stream of HTML by
the time it gets to the browser.
423
Search WWH ::




Custom Search