A discussion of the differences between JSP and servlet _jsp programming

Source: Internet
Author: User
Tags mixed
Answer one:

First you have to figure out what a servlet,servlet is a Java program that executes on the server side, except that it has a set of rules (what we normally call APIs); The JSP is simply a servlet program written in another set of simple rules that can write Java code, You can also write HTML code, JAVASCRIPT,CSS, and so on ..., but the server side is first turned into a servlet program and then executed in the order the servlet executes.

Answer two:

The following is from the Internet to find:
JSP and servlet in the end what is the difference in application, many people do not understand. Let me say a few words. In short, Sun first developed a servlet, its function is relatively strong, the system design is also very advanced, just, it output HTML statements or used the old CGI way, is a sentence output, so, write and modify HTML is very inconvenient.
Then Sun introduced a similar to the ASP Mosaic JSP, the JSP tag embedded in the HTML statement, so that greatly simplifies and facilitate the design and modification of the Web page. The new type of network language, such as asp,php,jsp, is a mosaic script language.

From the perspective of network three-layer structure, a network project is at least three layers: data layer,business layer, presentation layer. Of course, it can be more complicated. The servlet is powerful for writing business layer, but it is inconvenient to write presentation layer. JSP is mainly for the convenience of writing presentation layer design. Of course, you can write business layer. Write accustomed to asp,php,cgi friend, often unconsciously presentation layer and business layer mixed together. Like the previous friend, the database processing information into the JSP, in fact, it should be placed in the business layer.
According to Sun's own recommendation, JSP should only store the presentation layer, that is to say, only the part of the output HTML page. And all the data calculation, data analysis, database connection processing, all belong to business layer, should be placed in the Java beans. Call Java BEANS through JSP to achieve the integration of two tiers.
In fact, the DNA technology introduced by Microsoft in the near future, simply speaking, is asp+com/dcom technology. Completely similar to Jsp+beans, all presentation layer are completed by ASP, and all business layer are completed by com/dcom. By calling, you implement consolidation.
Why do you use these component technologies? Because the simple asp/jsp language is very inefficient, if a large number of user clicks, the Pure script language will soon reach his upper limit, and component technology can greatly increase the upper limit of the function, speed up the execution speed.

On the other hand, the pure script language will presentation layer and business layer mix together, cause the modification is inconvenient, and the code cannot reuse. If you want to modify a place, often involves more than 10 of pages of code, the adoption of component technology only the reorganization of the pieces can be.
To sum up, the servlet is an early imperfect product, write business layer very good, write presentation layer is very smelly, and two layers of mixed.
So, the introduction of Jsp+baen, with JSP write presentation layer, with Baen write business layer. Sun's own meaning is to use JSP instead of the servlet in the future.
However, this is not to say that learning a servlet is useless, in fact, you should start from the servlet, and then on the JSP, and then on the Jsp+bean.
Emphasis is: 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 asp+com and Jsp+bean all adopt component technology, all of the components are compiled first, reside in memory, and execute quickly. So, we often blow the servlet/jsp first compiled in memory after the execution of the speed advantage is gone.
Conversely, asp+com+iis+nt close integration, there should be a greater speed advantage present. Moreover, asp+com+iis+nt development efficiency is very high, although a lot of bugs.

So, why do you 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.
In addition, the speed of the current machine is getting faster, the Java speed disadvantage can be overcome quickly.
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.