13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 19JSP:Servlets Turned Inside OutIn our last chapter, the BudgetPro servlet example spent a lot of code generatingthe HTML output for the servlet to send back to the browser. If you want tochange the HTML for any page (for example, add a background color), youwould have to modify the Java code (obviously)—but you’re not really wantingto modify the logic of the servlet, you <strong>on</strong>ly want to tweak its output. TheHTML that a servlet generates can be scattered am<strong>on</strong>g output statements, stringc<strong>on</strong>catenati<strong>on</strong>s, classes, and method calls. Servlets, we might say, bury theHTML deep inside the code. We’re now going to take a look at JavaServerPages (JSP) which do the opposite—they expose the HTML and hide the codedown inside.This technique has been given the fancy descripti<strong>on</strong>, document-centricserver-side programs. They are “document-centric” because the HTML code isso visible—JSP c<strong>on</strong>tent looks like (and is) HTML with some additi<strong>on</strong>s. Theyare “server-side” because all the work is d<strong>on</strong>e <strong>on</strong> the server and all the additi<strong>on</strong>sand special features of JSP are boiled down to a simple stream of HTML bythe time it gets to the browser.423

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!