Unlike the compilation command, the Action Command notifies the servlet engine to process messages when compiling the command, while the Action Command is only the action during running. The compilation command works when compiling JSP into servlet, and the processing command can usually be replaced with JSP script, which is just a standardized way of writing JSP scripts.
(1) JSP: Forward the execution page to forward request processing to the next page.
(2) JSP: Param is used to pass parameters. It must be used together with other tags that support parameters.
(3) JSP: Include is used to dynamically introduce a JSP page.
(4) JSP: plugin is used to download JavaBean or applet to the client for execution.
(5) JSP: usebean: Create a JavaBean instance
(6) JSP: setproperty: Set the attribute value of the JavaBean instance
(7) JSP: getproperty: Get the attribute value of the JavaBean instance
(1) Forward Command
It is used to forward a page to another page. It can be either forwarded to a static html page, a dynamic JSP page, or a servlet in the container. Dynamic commands only need to be directly used in <>, static commands are <%>, and dynamic commands appear in pairs.
The Forward Command Format of JSP is as follows:
Jsp1.0 Syntax: <JSP: Forward page = "{relativeurl | <% = expression % >}"/>
For the above jsp1.1 specifications, the syntax is: <JSP: Forward page = "{relativeurl | <% = expression % >}">
{<JSP: Param ·/>}
</Jsp: Forward>
This syntax is used to add additional request parameters during forwarding. The added request parameter value can be obtained through the getparameter () method of the httpservletrequest class. When the Forward Command is executed, the address of the user request remains unchanged and is still a request, but the page content completely changes to the content of the target page of the forward. When the forward request is executed, the client's request parameters are not lost.
(2) include command
The include command is a dynamic include command, which is also used to contain a page. It does not import the compilation instructions of the include page, but is only inserted into the page by the body content of the imported page.
<JSP: Include page = "{relativeurl | <% = expression %>}" Flush = "true">
<JSP: Param name = "parametername" value = "parametervalue"/>
<JSP: Include/>
The flush attribute is used to specify whether the output cache is transferred to the imported file. If it is set to true, it is included in the imported file. If it is set to false, it is included in the original file. In earlier versions of jsp1.1, the value can only be set to false.
Note: include static: Compile command ----- combine two JSP pages into one Servlet
Include dynamic: Action Command ------ use include in servlet to introduce the content of the imported page
The compilation commands on the imported pages on the static import page must be consistent. Otherwise, an error occurs. The dynamic statements only contain the body part.
(3) userbean, setproperty, and getproperty commands
These three commands are related to JavaBean. The userbean command is used to initialize a Java instance on the JSP page, and the setproperty command is used to set values for the properties of the JavaBean instance; the getproperty command is used to output attributes of a JavaBean instance. If a code segment needs to be used repeatedly on multiple JSP pages, we can define this code as a Java class method, and then call this method on multiple JSP pages, this can achieve better code reuse.
The syntax format of userbean is as follows:
<JSP: userbean id = "name" class = "classname" Scope = "Page | request | session | application"/>
The ID attribute is the Instance name of JavaBean, and the class attribute determines the implementation class of the JavaBean. The scope attribute is used to specify the scope of a JavaBean instance.
Setproperty syntax format
<JSP: setproperty name = "beanname" property = "propertyname" value = "propertyvalue"/>
The name attribute determines the Instance name of the JavaBean, the property attribute determines the attribute name of the set attribute, and the Value Attribute determines the value corresponding to the attribute name.
Syntax format of getproperty
<JSP: getproperty name = "beanname" name = "propertyname"/>
For the name attribute, you must determine the Instance name of the JavaBean instance. The name attribute specifies the value corresponding to the attribute name to be obtained.
Note: when using the userbean tag, in addition to creating a JavaBean instance in the page script, the tag also puts the JavaBean instance into the specified scope, therefore, we also need to put the JavaBean in the specified scope in the script, as shown in the following code:
Pagecontext. setattribute ("beanname", beanname)
Request. setatttibutr ("beanname", beanname)
Session. setattribute ("beanname", beanname)
Application. setattribute ("beanname", beanname)
(4) plugin commands
The plugin command is mainly used to download the server-side JavaBean or applet to the client for execution. Because the program is executed on the client, the client must install the virtual machine.
(5) Param commands
Param is used to set the parameter value. This command cannot be used independently. Therefore, a separate Param command has no practical significance. The param command can be used in combination with the following command.
JSP: Include JSP: Forward JSP: plugin