Java Bean Technology in JSP development technology

Source: Internet
Author: User

The JavaBean specification introduces the concept of "software components" into the Java programming field. Javabean is a software component model that describes java. Its main purpose is to achieveCode.

Javabean is a Java class. Compared with a common Java class, it must comply with the following rules:

1. Implementation interface Java. io. serializable; Java "Object serialization" 2. JavaBean class provides a non-parameter constructor 3. attributes in JavaBean should be declared as private4 and attributes in JavaBean should be accessed through setxxx () and the getxxx () method. 5. The access attribute method in the JavaBean must be declared as public.

Attributes of JavaBean

Common three properties: simple attributes are usually a single-value attribute with a bunch of get/set methods. Boolean attribute: the setting method of a Boolean attribute is the same as that of a simple attribute. The method for getting a value is usually replaced by isxxx () instead of getxxx (). Index attribute: indicates a set attribute, such as an array and a list. Generally, two set methods and two get methods are provided for the index attribute. You can read and set the entire attribute or a single element value.

Java-related action tags: <JSP: usebean>, <JSP: setproperty>, and <JSP: getproperty>

Scope of application of JavaBean

The page range is limited to the current page and cannot be shared among multiple pages. The request range is limited to one request, which may span multiple pages and involve multiple Web components. The session range is limited to one session, it can contain multiple requests. The application has the largest range, which is the whole application and contains all sessions.
Related Article

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.