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.

432Chapter 19JSP: Servlets Turned Inside OutTable 19.1 JSP predefined variablesTypePageC<strong>on</strong>textHttpSessi<strong>on</strong>ServletC<strong>on</strong>textServletC<strong>on</strong>figJspWriterVariable namepageC<strong>on</strong>textsessi<strong>on</strong>applicati<strong>on</strong>c<strong>on</strong>figoutin your use of JSP. We have some good JSP references at the end of this chapterfor those who want all the gory details of this feature.is the way to provide Java import statements for your JSP. We bet you canguess what that happens in the generated servlet.Here’s another useful page directive:You’ll see this as the opening line of our JSP, to identify the output MIMEtype for our servlet.JSP also has an include directive:This directive is, for some applicati<strong>on</strong>s, worth the price of admissi<strong>on</strong> al<strong>on</strong>e.That is, it is such a useful feature that even if they use nothing else, they coulduse JSP just for this feature. It will include the named file when c<strong>on</strong>verting theJSP—that is, at compile time.It can be used for comm<strong>on</strong> header and footer files for a family of Webpages. (If you’re a C programmer, think #include.) By defining <strong>on</strong>e headerfile and then using this directive in each JSP, you could give all your JSP thesame look—say, a corporate logo and title at the top of page and a standardcopyright statement and hyperlink to your webmaster’s e-mail address atthe bottom.Be aware that this inclusi<strong>on</strong> happens at compile time and is a source-levelinclusi<strong>on</strong>. That is, you are inserting additi<strong>on</strong>al source into the JSP, so if your

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

Saved successfully!

Ooh no, something went wrong!