JSP compiler directives are information that notifies the JSP engine that it does not generate output directly. There are three common compiler directives:
Page directive
This directive is a descriptive instruction for the entire JSP page. The syntax format is as follows:
The% @page
[language= "Java"]
[extends= "Package.class"]
[import=] Package. Class|package. *},..."]
[session=] True| False "]
[buffer=] None| 8KB| Size KB "]
[autoflush=] True| False "]
[isthreadsafe=] True| False "]
[info= "Text"]
[errorpage= "Relativeurl"]
[contenttype= "mimetype[; Charset=characterset]" | " Text/html;charset= "808859-1"]
[iserrorpage=] True| False "]
%》
You can have more than one page directive in a JSP page. There are several attribute values in each page directive.
The Language property is used to describe the type of scripting language of the current page (that is, what kind of language is in parentheses).
Extends is used to describe the parent class inherited by the Java class translated by this JSP page, or an implemented interface.
Import is an imported package that is used when a primer is required in the script.
Session is used to indicate whether this JSP page needs to be httpsession.
buffer specifies the size of the output buffer virtual. The default value is 8k, but it is set to another size. The cache that is needed when the out-of-client output is used.
AutoFlush refers to whether the content of the output buffer needs to be forced when the output buffer is about to overflow. Normal output When set to true: if set to False, an exception is generated when buffer overflows.
Info: Set the JSP program's information, can also be seen as its description, you can write some descriptive text, you can pass the Servlet. The Getservletinfo () method gets the value. If you are in a JSP page, you can call the Getservletinfo () method directly to get the value, because the nature of the JSP page is Serlet.
ERRORPAGE Specifies the error handling page. If the program generates an exception or an error, and the JSP page does not have a corresponding processing code, the JSP page specified by the directive is automatically invoked. Using JSP pages, you can not handle exceptions, even if the checked exception, Yinwei JSP built an exception mechanism support. If an exception occurs, an unhandled exception is thrown, and no error interface is specified, the error message is displayed directly in the browser.
Iserrorpage sets whether this JSP page is an error handler. If the page itself is an error-handling page, you do not need to use the ErrorPage property.
ContentType: Used to set the file format and encoding of the generated Web page, that is, MIME type and page type, the default MIME type is textlhtml; The default character set is Iso-8859-1.
pageencoding specifies the encoded character of the generated Web page.
Include directives
It can include external JSP files in the current JSP page and parse the JSP statements in the external JSP (the four JSP statements mentioned in the previous section). Include can contain both static text and dynamic JSP pages. The static compilation directives include, which is to include the included pages and generate a complete page. So the included JSP can not be complete, anyway the final use is not it, as long as you can make up a complete can. in the servlet level, the include principle is to fuse the Java code of the included pages into the Java code of the current page. That's why this approach is called static, because it completely incorporates the code in the included interface and includes other compilation instructions. attention to prevent the conflict of compilation instructions! the Include static statements are as follows:
% @include file= "Relativeurlspec"%
If the embedded file often needs to be changed, it is recommended to use an action instruction (see section below) because it is a dynamic include statement. "Jsp:include page=" url "/" before the development, the index interface of the include is used in this way.
TAGLIB directive
This directive is used to indicate which tag library is introduced, what the prefix is, and what the URI is. This is described in more detail in the following sections.
This article from "Fingertip Light Fly" blog, declined reprint!
JSP note--3.jsp Three compilation instructions