The relationship between JSP, Servlet and JavaBean __java

Source: Internet
Author: User



The first book of two years learned the JSP, the servlet, and the JavaBean, and put them in a book, so what's the difference between them? Because I am a beginner can only according to their own understanding to talk about their differences, I think JSP is like a company's front desk staff, to long good, so that customers feel more comfortable at a glance, he is mainly responsible for showing the image of the hotel. The servlet, like the department manager, deals with a wide variety of businesses and things, and the bean is like a senior leader who gets information from the department manager, reports it to the board, or orders the board's advice and plans. They work with each other and do their jobs.

Look at the concrete below.

What is the difference between JSP and servlet in application? Sun first developed a servlet, its function is more powerful, the system design is also very advanced, but it output HTML statements or a sentence of output, so write and modify HTML is very inconvenient. Later, Sun launched a mosaic with HTML JSP, the JSP embedded into the HTML statement, so that greatly simplifies and facilitate the design and modification of the Web page.

From the perspective of three-layer structure, a project is at least three layers: data layer, business processing layer, and page display layer. Of course, it can be more complicated. The servlet used to write the business processing layer is powerful, but it is inconvenient for the write interface. JSP is mainly designed to facilitate the writing interface. Of course, you can also write business processing layer.

But in our study, JSP should only store the interface-related code, that is, only the part of the output HTML page. And all the data calculation, data analysis, database connection processing, all belong to the business process, should be placed in the Java beans. Call Java BEANS through JSP to achieve the integration of two tiers.

Why should we separate? It's really simple. If the pure script language mixes the interface with the data processing, it makes the modification inconvenient and the code cannot be reused. If you want to modify a place, you will change a lot of places, but if the use of component technology, only the reorganization of the pieces can be. To sum up, the servlet is not very perfect writing interface layer is very good, write data processing is not easy to use, and two layers of mixed. Therefore, the introduction of Jsp+baen, using JSP to write data processing, with Baen write interface.

Some people can not help to ask, that learning servlet useless, in fact, you should start from the servlet, then on the JSP, and then on the Jsp+bean. In this way you can learn the three languages well. It is worth emphasizing that: learning JSP, do not use Java bean and integration, is not learned. Let's spend a little more effort on the Jsp+bean. In addition to a few words:

As we can see, when Jsp+bean adopts component technology, all components are compiled first and reside in memory, and then executed quickly. So, we often blow the servlet/jsp first compiled in memory after the execution of the speed advantage is gone. So, why use Jsp+bean. Because Java is really promising. After the break-up of Microsoft, the operating system will be the same, the application software developers must find a common development language for development, Java Eminence time to. If Microsoft splits smoothly, the application software companies that are separated from it will become the new leader of Java. The current Java Big Head Sun and IBM are lifeless, disappointing. Hope the new company can inject new vigor. However, the new company is likely to start the Java Standard War with the old Sun, the two sides set standards, Impact Java platform. These are the things I learned from my friends.

In addition, the speed of the current machine is getting faster, the Java speed disadvantage can be overcome quickly.

So we must learn JSP, servlet and JavaBean.

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.