Today, I reviewed the JSP instruction elements and sorted them out to share with you:
I. page commands:Sets the global attribute of the JSP page. This configuration acts on the entire JSP page and sets static files.
<% @ Page property 1 = "attribute value 1" attribute 2 = "attribute value 2" %>
1. language attribute: Declares the type of the scripting language used. Currently, only one type of java is available, and other languages will not be excluded.
<% @ Page language = "java" %>
2. extends attributes: Specify the parent class to which the Servlet generated on the JSP page inherits. You must specify the full name of the class, that is, the package name and class name. Use less, use with caution, may limit the JSP page compilation capability.
<% @ Page extends = "inherited parent class" %>
3. import attribute: Specifies the imported java package. It can be a class file under the directory specified in the environment variable, or a custom file in the classes directory under the web Project WEB-INF. The default imported JSP package is as follows:
Java. lang. *; javax. servlet. *; javax. servlet. jsp. *; javax. servlet. http .*;
<% @ Page import = "imported package name" %>
4. session attribute: Specifies whether the session object can be used on the JSP page. If it is set to true, the session object can be used. If it is set to false, the session object cannot be used. The default value is true.
<% @ Page session = "true | false" %>
5. buffer attribute: specify whether the output stream has a buffer and set the buffer size. None does not have the buffer function, or other specific values. The default value is 8 KB.
<% @ Page buffer = "none | nkb" %>
6. autoFlush attribute: Specifies whether the buffer is automatically forced to output. The default value is true. If this parameter is set to true, the output is still normal when the buffer is full. If it is set to false, an exception occurs. When buffer is set to none, it cannot be set to false.
<% @ Page autoFlush = "true | false" %>
7. isThreadSafe attribute: specifies that JSP pages can be used in multiple threads. true supports multiple threads and can process requests from multiple users. false does not support only one user, the default value is true.
<% @ Page isThreadSafe = "true | false" %>
8. info attribute: Set information about the JSP page, which can be any string. You can use Servlet. getServletInfo to obtain this information.
<% @ Page info = "this is a jsp page" %>
9. errorPage attribute: When an exception occurs, it jumps to the JSP file that can handle the exception.
<% @ Page errorPage = "error. jsp" %>
10. isErrorPage attribute: whether to handle abnormal JSP files. The default value is false.
<% @ Page isErrorPage = "true | false" %>
11. contenType attribute: Specify the MIME format of the JSP page and the encoding format of the webpage. Default format is ISO-8859-1.
<% @ PagecontenType = "txt/html; charset =" ISO-8859-1 "%>
12. pageEncoding attribute: Specify the webpage encoding format.
<% @ PagepageEncoding = "ISO-8859-1" %>
13. isELIgnored attribute: whether EL expressions are supported. If it is true, this attribute is ignored and not executed. The default value is false.
<% @ PageisELIgnored = "ture | false"
%>
Ii. include command:Insert a file that contains text or code into the JSP file. When the file is converted into a servlet, the file that can now be merged with the current file, and the contained file is executed, the JSP page is resumed.
<% @ Include = "included file address"
%>
1. Include text files: add the contentType attribute if there are Chinese characters.
Such as text content:
<% @
Page contenType = "txt/html; charset =" gb2312 "%>
This is a text file.
2. contains html files.
For example, html content:
<Button> check </button>
3. Contains jsp files.
<% Date
Now = new Date ();
Out. println (now );
%>
Iii. taglib commands:Declare that the JSP file uses a custom tag.
<% @ Taglib
Uri = "URIToTagLibrary" prefix = "tagPrefix" %>
1. uri attribute: used to specify the storage location of the tag library.
2. prefix attribute: Specify the prefix required by the tag library.
Example: <% @ taglib
Uri = "http: java.sun.com/../core" prefix = "c" %>
Use tags: <c: out value = "this is blue! ">