The difference between JSP and Servlets

zhaozj2021-02-16  107

The difference between JSP and Servlets

??????? JSP and servlet What is the difference in the app, many people are unclear. Let me have a few words. Simply put, Sun first develops servlet, which is relatively strong, and the system design is also very advanced. It is just that it outputs an HTML statement or an old CGI mode. It is an output, so it is very inconvenient to write and modify HTML. Later, Sun launched a mosquesped JSP similar to ASP, inlaid JSP Tag into the HTML statement, which greatly simplifies and makes the design and modification of the webpage. New network languages ​​such as ASP, PHP, JSP are all inlaid Script languages. From the perspective of the three-layer structure of the network, a network program minimum 3 layers: Data Layer, Business Layer, Presentation Layer. Of course, it can also be more complicated. Servlets are very powerful, but it is very inconvenient to write Presentation Layer. JSP is mainly designed for convenience to write Presentation Layer. Of course, you can also write Business Layer. Write a friend who is used to ASP, PHP, and CGI, often uncomfortably mixing Presentation Layer and Business Layer. Just like the friend, put the database processing information in JSP, in fact, it should be placed in Business Layer. According to Sun's own recommendation, JSP should only store Dongdong related to Presentation Layer, which means that only part of the HTML web page is output. All data calculations, data analysis, database linkage processing, all of which belong to Business Layer, should be placed in Java Beans. Call JAVA Beans through JSP to implement two layers of integration. In fact, DNA technology launched in front of Microsoft, simply, is ASP COM / DCOM technology. Similar to JSP Beans, all Presentation Layer is done by ASP, and all Business Layer is done by COM / DCOM. Integration by calling and implementing. Why use these components technology? Because simple ASP / JSP language is very low efficiency, if a large number of users click, the pure script language will arrive quickly from his functional upper limit, and component technology can greatly improve the functional upper limit, speed up the execution speed. On the other hand, pure script language is mixed with Presentation Layer and Business Layer, causing inconvenience, and code cannot be reused. If you want to modify a place, you will often involve a dozen pages of Code. You can only change the components using component technology. In summary, servlet is an early imperfect product, written in Business Layer, is very stinking with Presentation Layer, and two layers are mixed. So, launch JSP BAEN, Write Presentation Layer with JSP, write business layer with Baen. Sun you mean is also an alternative servlet in the future. However, this is not to say, learn the servlet is useless. In fact, you should still get started from the servlet, then JSP, then JSP Bean. Emphasized: learning JSP and does not integrate with Java Bean, equal to no learning. Everyone spends more effort on JSP Bean.

转载请注明原文地址:https://www.9cbs.com/read-10417.html

New Post(0)