Chapter 12. Controlling the Structure of Generated Servlets: The JSP page Directive

Chapter 12. Controlling the Structure of Generated Servlets: The JSP page Directive

Topics in This Chapter

  • Understanding the purpose of the page directive

  • Designating which classes are imported

  • Specifying the MIME type of the page

  • Generating Excel spreadsheets

  • Participating in sessions

  • Setting the size and behavior of the output buffer

  • Designating pages to handle JSP errors

  • Controlling threading behavior

  • Using XML-compatible syntax for directives

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.



Core Servlets and JavaServer Pages (Vol. 1.Core Technologies)
Core Servlets and Javaserver Pages: Core Technologies, Vol. 1 (2nd Edition)
ISBN: 0130092290
EAN: 2147483647
Year: 2002
Pages: 194

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