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 oppositethey 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 visibleJSP 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.



    Java Application Development with Linux
    Java Application Development on Linux
    ISBN: 013143697X
    EAN: 2147483647
    Year: 2004
    Pages: 292

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net