JSP instruction element of page instruction and include instruction and taglib instruction review

  • 2020-06-03 08:04:01
  • OfStack

Today, I have reviewed the elements of JSP instruction and sorted them out. I would like to share with you from 1.

1. page instruction: Set the global property of JSP page. This configuration applies to the entire JSP page, including files contained statically.
< % @page property 1= "property value 1" property 2= "property value 2" % >
1. language attribute: declare the type of scripting language used. At present, there is only java1.
< "% % @ page language =" java >
2. extends attribute: Specify which parent class the Servlet generated by the JSP page is inherited from. The full name of the class must be specified, that is, package name plus class name. Use sparingly, with caution, and may limit the compilation ability of JSP pages.
< % @page extends= "inherited parent class" % >
3. import attribute: Specify the imported java package, which can be a class file in the directory specified in the environment variable, or a custom file in the classes directory under web project ES33en-ES34en. JSP imports the following packages by default:
java.lang.*;javax.servlet.*;javax.servlet.jsp.*;javax.servlet.http.*;
< % @page import=" Imported package name "% >
4, session attribute: Specify whether session object can be used on JSP page, true is ok, false is not, default is true.
< % @ page session = "true | false" % >
5. buffer property: Specify whether the output stream has a buffer, and set the buffer size. none does not have buffering or other specific values and defaults to 8kb.
< % @ page buffer = "none | nkb" % >
6. autoFlush attribute: Specify whether the buffer is automatically forced output, default is true. When it is true, the output remains normal when the buffer is full, and an exception occurs when it is false. When buffer is none, it cannot be set to false.
< % @ page autoFlush = "true | false" % >
7, isThreadSafe attribute: specify JSP page is enough to support the use of multithreading, true support multithreading, can handle multiple user requests at the same time, false can not, can only be a user, default is true.
< % @ page isThreadSafe = "true | false" % >
8, info property: set JSP page related information, can be any string. This information is available through ES100en.getServletInfo.
< % @page info= "this is a jsp" % >
9. errorPage attribute: When an exception occurs, jump to the JSP file that can handle the exception.
< % @ page errorPage = "error. jsp" % >
10. isErrorPage attribute: Whether the JSP file can handle exceptions. Default is false.
< % @ page isErrorPage = "true | false" % >
11. contenType attribute: Specifies the MIME format of the JSP page and the encoding format of the page. The default format is ISO-8859-1.
< % @ pagecontenType = "txt/html; charset = "ISO - 8859-1" % >
12. pageEncoding attribute: Specifies the encoding format of the web page.
< % @ pagepageEncoding = "ISO - 8859-1" % >
13, isELIgnored attribute: whether EL expression is supported or not, true is ignored, do not execute. Default is false.
< % @ pageisELIgnored = "ture | false"
% >

2. include instruction: insert 1 file containing text or code in THE JSP file, merge the current file with the current file when converted to servlet, and the execution of the JSP page will resume after the execution of the included file.
< % @include = "File address included"
% >
1. Include text file: Add contentType attribute if Chinese is available.
Such as text content:
< %@
txt/html page contenType = "; charset = "gb2312" % >
This is a text file.
2. Contains html files.
For example, html
< button > check < /button >
3. jsp file is included.
< %Date
now = new Date();
out.println(now);
% >

3. taglib directive: states that the JSP file USES a custom label.
< %@taglib
uri="URIToTagLibrary" prefix="tagPrefix" % >
1. uri attribute: Used to specify the location of the tag library.
2. prefix attribute: Specifies the prefix that the tag library must use.
Such as: < %@taglib
uri="http:java.sun.com/.../core" prefix="c" % >
Use labels: < c:out ="this is" >

Related articles: