The application of JavaBean in JSP __div

Source: Internet
Author: User
Tags access properties

1, what is JavaBean

JavaBean is an important component in Java that can be cross-platform, and it is a component architecture. JavaBean in the server side of the application shows a strong vitality, in the JSP program commonly used to encapsulate business logic, database operations.

JavaBean is actually a Java class, and this class can be reused. From the JavaBean function can be divided into: packaging data and encapsulation business.

JavaBean is a public class and provides an parameterless, publicly constructed method. property is private. Getter and setter methods that have public access properties.

1.1, a javabean of encapsulated data typically corresponds to a table (or view) within the database, and the JavaBean property corresponds to the property one by one of the field in the table (or view). Relative to the javabean of a encapsulated data, there is usually a javabean that encapsulates the business logic and business operations of the class.

2. The object-oriented thought of JavaBean

When a method has a lot of parameters, one argument is very troublesome. From an object-oriented perspective, when a business recovery operation database table, it is only possible to pass to the method a corresponding instance object to the table. The object contains the values of each field in the table, and there is only one argument, and the passed argument is the JavaBean object (the Java class object).

3, JSP standard action

The JSP standard action executes when the browser requests the page, and the JSP standard action can use existing JavaBean components and attributes, and transfer the user request to another page.

The JSP standard action uses <jsp:> as the prefix, the attributes in the JSP standard action are case-sensitive, and the values in the attribute must be enclosed in quotation marks.

The benefits of using JSP standard actions are that they can be easily developed and reflected in the reuse of code. can be convenient for artists to beautify the page, in the JSP reduced a lot of Java code. Simplifies the process of acquiring and encapsulating data.

3.1, Jsp:usebean action is used to load a javabean that will be used in JSP pages. The syntax is as follows:

<jsp:usebean id= "name" class= "Package.class" scope= "Scope"/>

The ID is used to create the JavaBean reference name and to create the name of the object. Class is used to specify JavaBean classes and to create types of objects. Scope is used to specify the range of JavaBean, the scope of the object, and the default setting is page.

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.