Seven common JSP action commands and jsp action commands

Source: Internet
Author: User

Seven common JSP action commands and jsp action commands

Common seven action commands in JSP


1. jsp: forward Command

Execute page redirection and forward request processing to the next page


2. jsp: param command

Used to PASS Parameters


3. jsp: include command

Used to dynamically introduce a JSP page


4. jsp: plugin command

Used to download JavaBean or Applet to the client for execution


5. jsp: useBean command

Create a JavaBean instance


6. jsp: setProperty command

Set the attribute value of the JavaBean instance


7. jsp: getProperty command

Obtain the attribute value of a JavaBean instance.



Common jsp commands

This is what you asked!

Edit nine built-in JSP objects in this section:
Request, response, out, session, application, config, pagecontext, page, exception.
I. request object:
This object encapsulates the information submitted by the user. You can call the corresponding method of this object to obtain the encapsulated information, that is, you can use this object to obtain the information submitted by the user.
Ii. response object:
Send data to the client in a dynamic response to the customer's request.
Iii. session Object
1. What is session: the session object is a JSP built-in object, which is automatically created when the first JSP page is loaded to complete session management.
A session starts when a client opens a browser and connects to the server, and ends when the client closes the browser and leaves the server. When a customer accesses a server, it may connect several pages of the server and refresh a page repeatedly. The server should know in some way that this is the same customer, this requires the session object.
2. session Object ID: when a customer visits a JSP page on the server for the first time, the JSP engine generates a session object and assigns a String-type ID, the JSP engine sends this ID number to the client and stores it in the Cookie, so that the session object and the customer have a one-to-one correspondence relationship. When the customer accesses other pages connected to the server, it will not allocate new session objects to the customer until the client closes the browser, and the session objects of the client on the server will be canceled, and the relationship with the customer's session disappears. When the client re-opens the browser and connects to the server, the server creates a new session object for the client.
Iv. aplication object
1. What is application:
After the server is started, this application object is generated. When the client browses between pages of the accessed website, the application object is the same until the server is closed. However, unlike session, all customers share the same application object.
2. Common Methods for application objects:
(1) public void setAttribute (String key, Object obj): add the Object obj specified by the parameter Object to the application Object, and specify an index keyword for the added Object.
(2) public Object getAttribute (String key): obtains the Object containing keywords in the application Object.
V. out object
An out object is an output stream used to output data to the client. The out object is used to output various types of data.
6. page java. lang. Object
Corresponds to the this keyword. JSP page itself
The page object is an instance of the Servlet class after the current page is converted. From the converted Servlet class code, we can see this relationship:
Object page = this;
In JSP pages, page objects are rarely used.
7. config
Javax. servlet. ServletConfig instance, which represents the configuration information of the JSP. Common methods include getInitPararneter (String paramNarne) and getInitPararneternarnes. In fact, JSP pages do not need to be configured, so there is no configuration information. Therefore, this object is more effective in Servlet.
8. exception
J... the remaining full text>

What commands and action labels in 2JSP?

Action commands in JSP Include, Forward, UseBean, GetProperty, SetProperty, and Plugin.

I. Include commands

<Jsp: include> the tag indicates a static or dynamic file.

Syntax:
<Jsp: include page = "path" flush = "true"/>
Or
<Jsp: include page = "path" flush = "true">
<Jsp: param name = "paramName" value = "paramValue"/>
</Jsp: include>

Note:
1. page = "path" is a relative path or a relative path expression.
2. flush = "true" must be set to true. The default value is false.
3. The <jsp: param> clause allows you to pass one or more parameters to a dynamic file. You can also use multiple <jsp: param> to pass multiple parameters to a dynamic file.

Ii. Forward Command

<Jsp: forward> the tag indicates redirecting a static html/jsp file or a program segment.

Syntax:
<Jsp: forward page = "path"}/>
Or
<Jsp: forward page = "path"}>
<Jsp: param name = "paramName" value = "paramValue"/> ......
</Jsp: forward>

Note:
1. page = "path" is an expression or a string.
2. <jsp: param> name specifies the parameter name and value specifies the parameter value. The parameter is sent to a dynamic file. The parameter can be one or more values, but the file must be a dynamic file. To pass multiple parameters, you can use multiple <JSP: param> In a jsp file to send multiple parameters to a dynamic file.

Iii. UseBean instructions

<Jsp: useBean> A tag is used to create a BEAN instance on the JSP page and specify its name and scope.

Syntax:
<Jsp: useBean id = "name" scope = "page | request | session | application" typeSpec/>
TypeSpec has the following possibilities:
Class = "className" | class = "className" type = "typeName" | beanName = "beanName" type = "typeName" | type = "typeName" |

Note:
You must use class or type instead of both class and beanName. BeanName indicates the Bean name in the form of "a. B. c ".

Iv. GetProperty command

<Jsp:... the remaining full text>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.