1. JSP commands
Category: 1). page 2). include 3). taglib
Syntax: <% @ command name attribute 1 = "value 1"... %>
2. Page compilation command:
• Purpose: Use the Page compilation command to set the Page attributes of JSP. Usually located at the top of the JSP page, you can have multiple page commands for the same page.
• Page command syntax format:
Copy codeThe Code is as follows:
<% @ Page
[Language = "Java"] // declare the type of language used for JSP pages
[Extends = "package. class"] // Java class generated during JSP program compilation, the parent class to be inherited, or the fully qualified class name of the interface to be implemented
[Import = "package. class | package. *},..."] // import the package. Automatically imported packages by default: java. lang. *; javax. servlet. *; javax. servlet. jsp. *; javax. servlet. http .*
[Session = "true | false"]
[Buffer = "none | 8kb | size kb"]
[AutoFlush = "true | false"]
[IsThreadSafe = "true | false"]
[Info = "text"]
[ErrorPage = "relativeURL"] // specifies the error handling page
[ContentType = "mimeType [; charset = characterSet]" | "text/html; charSet = ISO8859-1"]
[IsErrorPage = "true | false"] // sets this JSP page as an error handler
%>
3. Include compilation instructions
• Role:
The notification container will include a static file during the interpretation of the current JSP page, and the file content can be parsed by JSP during compilation. On the JSP page, the include command has no limit and can be nested. Theoretically, nesting is unrestricted. However, all pages must use the same script language as include pages.
• Include syntax format:
<% @ Include file = "relativeURL" %>
• Benefits of using include to compile commands:
A complex JSP page can be divided into several simple parts that can be processed separately. This method greatly enhances the management, flexibility, and extended type of JSP pages. When you want to modify a page, you can only modify the contained files to be modified.
• Note:
1) <% @ include file = "test2.jsp" %> error in test1.jsp.
Error: Multiple annotations found at this line:
-Duplicate local variable path
-Duplicate local variable
Solution:
Method I: Change path and basepath in test2.jsp to another name.
Method II: delete path and basepath in test2.jsp