Jsp + JavaBean step-by-step tutorial (1)
--------------------------------------------------------------------------------
Jsp + JavaBean step-by-step tutorial (1)
(Text/Liu Yufeng)
Currently, Jsp is widely used as a good dynamic website development language. In various Jsp applications, Jsp
+ The combination of Java beans has become the most common Jsp Program Standard. Let's take a look at how the specific Jsp corresponds
Java Bean.
This tutorial describes the principles of JavaBean, and then describes the specific syntax of JavaBean under the assumerver Page.
Demonstrate a simple counter using Jsp + JavaBean. At last, we will explain in detail a an + jsp with database functions.
.
Principles and Applications of Java Bean
1. What is JavaBean?
JavaBean is a software component model describing Java, which is somewhat similar to Microsoft's COM component concept. In the Java model,
Java program functions can be infinitely expanded through JavaBean, and new applications can be quickly generated through the combination of JavaBean.
For programmers, the best thing is that JavaBean can reuse code, and it is easy to maintain programs.
It also has great significance.
Java Virtual Machine (Java Virtual Machine) can be used to run JavaBean correctly.
A small requirement is JDK1.1 or later.
The traditional application of JavaBean lies in the field of visualization, such as applications under AWT. Since the birth of Jsp, more an applications
In the field of non-visualization, server applications are becoming increasingly active. Here we mainly discuss right and wrong.
Visualized JavaBean and visualized JavaBean are described in detail in many Java books on the market.
Important.
2. Non-visual JavaBean
Non-visualized JavaBean, as its name implies, is a JavaBean without a GUI. It is often used to encapsulate the transaction commit in Jsp programs.
Database operations, and so on, can well achieve the separation of business logic and foreground programs (such as jsp files), so that the system has a better
Robustness and flexibility.
A simple example, such as a shopping cart program, to add a commodity to the shopping cart, you can write
Create a public AddItem member method for the JavaBean operated by a shopping cart. The front-end Jsp file directly calls this
Method. If you want to add the goods later, you need to determine whether there is any goods in the inventory, and you cannot purchase the goods without it.
In this case, you can directly modify the AddItem method of JavaBean and add the processing statement to implement it.
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.