JSP compile instruction page include detail

  • 2020-10-23 20:15:39
  • OfStack

1. JSP instructions

Classification: 1).page 2).include 3).taglib

Grammar: < %@ instruction name attribute 1=" value 1"... % >

2. Page compilation instruction:

The & # 8226; Effect: You can set the page properties of JSP using the Page compile directive. Usually at the top of an JSP page, you can have more than one page instruction on the same page.
The & # 8226; page instruction syntax format:


<%@page
[language="Java"]    // The statement JSP The type of language the page USES 
[extends="package.class"]    //JSP Produced when a program is compiled Java Class, 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.*},..."]    // Used to import packages. 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"]         // Specify the error handling page 
[contentType="mimeType [ ;charset=characterSet]" | "text/html;charSet=ISO8859-1"]
[isErrorPage="true | false"]        // Set up the JSP The page is an error handler 
%>

3. Include compile instruction

The & # 8226; Function:
Notifies the container that the current JSP page will contain a static file during interpretation, and that the contained file content can be parsed by JSP during compilation. On the JSP page, the include directive has no number limit and can be used nested. In theory, nesting is unlimited, but all pages must use the same scripting language as include's pages.

The & # 8226; include syntax format:
< % % @ include file relativeURL = "" >

The & # 8226; Benefits of compiling instructions using include:
You can break up a complex JSP page into several simple parts that can be processed separately. This approach greatly enhances the manageability and flexibility and extensibility of JSP pages. When you want to modify a page, you can modify only the included file you want to modify separately.

The & # 8226; Notes:
1) In test1.jsp < %@ include file="test2.jsp" % > An error occurred.

Error: Multiple annotations found at this line:
- Duplicate local variable path
- Duplicate local variable

Solutions:

I: Change path and basepath in test2.jsp to other names

II: Delete path and basepath from test 2.ES82en


Related articles: