Chapter 12. Controlling the Structure of Generated Servlets: The JSP page Directive
Topics in This Chapter
A JSP directive affects the overall structure of the servlet that results from the JSP page. The following templates show the two possible forms for directives. Single quotes can be substituted for the double quotes around the attribute values, but the quotation marks cannot be omitted altogether. To obtain quotation marks within an attribute value, precede them with a backslash, using \' for ' and \" for " .
<%@ directive attribute =" value " %> <%@ directive attribute1 =" value1 " attribute2 =" value2 " ... attributeN =" valueN " %>
In JSP, there are three main types of directives: page , include , and taglib . The page directive lets you control the structure of the servlet by importing classes, customizing the servlet superclass, setting the content type, and the like. A page directive can be placed anywhere within the document; its use is the topic of this chapter. The second directive, include , lets you insert a file into the JSP page at the time the JSP file is translated into a servlet. An include directive should be placed in the document at the point at which you want the file to be inserted; it is discussed in Chapter 13. The third directive, taglib , defines custom markup tags; it is discussed at great length in Volume 2 of this book, where there are several chapters on custom tag libraries.
The page directive lets you define one or more of the following case-sensitive attributes (listed in approximate order of frequency of use): import , contentType , pageEncoding , session , isELIgnored (JSP 2.0 only), buffer , autoFlush , info , errorPage , isErrorPage , isThreadSafe , language , and extends . These attributes are explained in the following sections.