JSP has three directives:
(1) Page: Used to define global properties in a JSP file
(2) include: Used to include the content of another file in a JSP page
(3) Taglib: This command allows the user to customize the new label
The third instruction is that the user defines the label according to the business requirements, facilitates the implementation of the function, but makes the code not easy to read, so the tags are some company development with an instance. The following mainly describes the use of the first two directives.
Common properties of 1.page directives and how to use them
(1) Language Declaration scripting language, currently only available in Java
<% @page language= "java"%>
(2) extends inherited by super-class
<% @page extends= "Com.lihui.util"%>
(3) Import sets the file to be used in the script element of the JSP file, the introduced class file can make the class file under the directory specified in the system environment variable, or the jar package in the \common\lib subdirectory under the container Tomcat root directory, or under the WEB project under construction web_ The jar package stored in the Inf\lib. For example:
<% @page import= "java.sql.*"%>
(4) Session Set whether this page requires session sessions, the default is available.
<% @page session= "false"%>
(5) Info Specifies the information for the JSP page, which can be obtained using the Getservletinfo () method
<% @page info= "This is my info"%>
(6) Whether the iselignored supports El expressions
<% @page iselignored= "false"%>
(7) Iserrorpage indicates whether the page can be used as error handling for other pages
<% @page iserrorpage= "false"%>
(8) ErrorPage and the previous property are used together. For example, the above attribute is defined as true in the a.jsp file, you can use the following in b.jsp
<% @page errorpage= "a.jsp"%>
(9) ContentType specifies the MIME type of the JSP page and the character encoding format used by this JSP page, which is passed to the client first. There are several MIME types: Text/plain text/html text/xml image/gif image/jpeg. The default character encoding is iso-8859-1. Settings are as follows:
<% @page contenttype= "text/html; Charset=iso-8859-1 "%>
2. How to use the include directive
This directive is used to merge the included files with the current file, which can be implemented in the JSP to contain text, JSP or other format of the file, you can implement the modular editing of the Web page. Typically, some parts of many pages in an application are used together to reduce code duplication.
<% @include file= "\page\lihui.jsp"%>
The path here is relative to the path, for example, a.jsp to load lihui.jsp, a.jsp stored in the. \webapps\test\page, lihui.jsp stored in the. \webapps\test\lihui, the path should be: \test\lihui
JSP page directives