1. JSP instruction
Category: 1). Page 2). Include 3). Taglib
Syntax: <%@ directive name Attribute 1 = "Value 1" .....%>
2. Page compilation Instructions:
• Function: You can set the page properties of a JSP using page compilation directives. Usually at the top of a JSP page, you can have multiple page directives for the same page.
page instruction Syntax format:
Copy Code code as follows:
<% @page
[language= "Java"]//declaring the type of language used in JSP pages
[extends= ' package.class]//jsp the Java class that is generated when the program compiles, the parent class that needs to be inherited, or the fully qualified class name of the interface that needs to be implemented
[Import= package.class | package.*},...]//To import the package. Default automatically imported packages: 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"]//Specify Error-handling page
[contenttype= "mimetype [; Charset=characterset]" | "Text/html;charset=iso8859-1"]
[Iserrorpage= ' true | false ']//Set this JSP page to be an error handler
%>
3. Include compilation instructions
Role
The notification container will include a static file in the interpreted process of the current JSP page, while the content of the contained file can be parsed by the JSP parsing process occurs during compilation. In a JSP page, the include directive is not limited in number and can be nested. In theory, nesting is unrestricted, but all pages must use the same scripting language as the Include page.
include syntax format:
<%@ include file= "Relativeurl"%>
• Benefits of using include compilation directives:
You can split a complex JSP page into several simple, individually-handled parts. This approach greatly enhances the management and flexibility and extensibility of JSP pages. When you want to modify a page, you can modify only the included file that you want to modify.
• Attention MATTERS:
1 in test1.jsp <%@ include file= "test2.jsp"%> error occurred.
Error: Multiple annotations found at this line:
-Duplicate local variable path
-Duplicate local variable
Workaround:
Method I: Change path and BasePath in test2.jsp to other names
Method II: Remove the path and basepath from the test2.jsp