The difference between JSP and Servlets

Source: Internet
Author: User
Tags execution html page iis mixed modify advantage
Js|servlet| distinguish between 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.





later, Sun introduced a similar to 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 point of view 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 Dongdong related to 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, Microsoft's DNA technology, 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 mixes presentation layer and business layer, making it inconvenient to modify, and the code cannot be reused. 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.





in summary, 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.





emphasized that: learning JSP, do not use Java bean and integration, is not learned. Let's spend a little more effort on the Jsp+bean.





Add a few words:





we can see that when both asp+com and Jsp+bean are using component technology, all 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.





on the contrary, asp+com+iis+nt close integration, should have a greater speed advantage present. Moreover, asp+com+iis+nt development efficiency is very high, although a lot of bugs.








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.