JavaBean's Three tags

Source: Internet
Author: User
I. <jsp:useBean>
This tag is used to declare and instantiate the JavaBean class. The syntax is as follows:
<jsp:usebeanid= "Object-name" scope= "page | Request | Session | Application "type=" Type-of-object "class=" Fully-qualified-classname "beanname=" Fully-qualified-beanname "/>"
Let's take a look at these properties:
ID-the name of the object, such as: String name = null; In this code, name is the ID;
scope--an optional attribute, when your JavaBean object will be corrupted, the default is page, and he means that each page will create a new JavaBean;
Type---An object of the same class or parent class, or an interface to be executed by that class, and his arguments are optional. For example: string name = "Faisal Khan"; string is what we talk about.
Class--a fully qualified category such as: Date d = new Java.util.Date (); Java.util.Date is what we call it.
beanname--is also a class that is fully qualified (fully qualified);
II. <jsp:setProperty>
This tag is used to design javabean values, the syntax is as follows:
<jsp:setpropertyname= "Id-of-the-javabean" property= "Name-of-property" param= "Name-of-request-parameter-to-use" "Value=" New-value-of-this-property "/>
The attribute is:
name--you set the ' id ' of the <jsp:useBean>
Property-the name you want to set
param--the name of the param you want to request in this property.
Value---The new values you want to set in this property
Iii. <jsp:getProperty>
This tag is used to return a particular property from a particular JavaBean, the syntax is as follows:
<jsp:getpropertyname= "Name-of-the-object" property= "Name-of-property"/>
' ID ' set in property:name--<jsp:usebean>
property--the name of the property you want to retrieve.
Well, now that we've finished learning to operate JavaBean JSP tags, let's take a moment to learn what the scope attribute is:
Each JavaBean class object, or other class object, has a scope (scope), meaning how long the object is kept in memory, where there are four scopes:
page--He means table A new object will be created or destroyed at each page level, and when you do not explicitly assign other values, he is <jsp:useBean> default.
Request--

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.