Java Reference
In-Depth Information
Table 19.1 JSP predefined variables
Type
Variable name
PageContext
pageContext
HttpSession
session
ServletContext
application
ServletConfig
config
JspWriter
out
in your use of JSP. We have some good JSP references at the end of this chapter
for those who want all the gory details of this feature.
<%@page import="package.name.*" %>
is the way to provide Java import statements for your JSP. We bet you can
guess what that happens in the generated servlet.
Here's another useful page directive:
<%@page contentType="text/html" %>
You'll see this as the opening line of our JSP, to identify the output MIME
type for our servlet.
JSP also has an include directive:
<%@include file="relative path" %>
This directive is, for some applications, worth the price of admission alone.
That is, it is such a useful feature that even if they use nothing else, they could
use JSP just for this feature. It will include the named file when converting the
JSP—that is, at compile time.
It can be used for common header and footer files for a family of Web
pages. (If you're a C programmer, think #include .) By defining one header
file and then using this directive in each JSP, you could give all your JSP the
same look—say, a corporate logo and title at the top of page and a standard
copyright statement and hyperlink to your webmaster's e-mail address at
the bottom.
Be aware that this inclusion happens at compile time and is a source-level
inclusion. That is, you are inserting additional source into the JSP, so if your
Search WWH ::




Custom Search