JavaBean Primer (1) JavaBean Introduction and basic use

Source: Internet
Author: User

JSP without JavaBean is equivalent to not learning JSP. In fact, from the beginning of JavaBean has entered the MVC pattern of learning. So what is JavaBean.

You remember when you JSP+JDBC connect to the database. As long as the page that needs to connect to the database will write the code about the database connection, then many pages are writing duplicate code. So is there a way to extract the code that repeats each page and put it on a common page, and then each page accesses the page. This avoids the practice of writing duplicate code in each page. The answer must be yes, the public page is JavaBean.

JavaBean Introduction

JavaBean is a reusable component developed using the Java language, which can be used to reduce repetitive code in the development of JSP, making the development of the whole JSP code more concise. Like what:

1. You can separate HTML and Java code so that you can achieve team collaboration for your project. To make the code clear and distinguishable

2. Avoid duplication of code writing, write commonly used programs as JavaBean components.

What is JavaBean?

As mentioned above, the code that repeats each page is extracted and put into a public page, and this page is what we call JavaBean. So what is this page? is the. java file. It's the one you built when you were learning Java. class. The following figure: in the development tool yellow area Simplebean.java is actually a javaBean, and our project is javabean_01.jsp,javabean_01.jsp will call Simpbean inside content.

For JavaBean, there are several nouns that I hope you will know:

VO: A value object that holds all the data.

POJO: Simple Java objects

To: Transfer objects, a class must implement the serializable interface to be called a transport object.

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.