Differences between Servlets and JSP

Source: Internet
Author: User

What is the difference between SERVLET and JSP in the application? Many people are confused. Let me say a few things. Simply put, SUN first developed the SERVLET, which has powerful functions and advanced system design. However, it still uses the old CGI method to output HTML statements, therefore, it is inconvenient to write and modify HTML. Later, SUN introduced an embedded JSP similar to ASP and embedded the jsp tag into an HTML statement. This greatly simplifies and facilitates the design and modification of webpages. New Network languages such as ASP, PHP, and JSP are embedded SCRIPT languages.

From the perspective of the three-tier network structure, a network project can be divided into at least three layers:
◆ Data layer
◆ Business layer
◆ Presentation layer.

Of course, it can be more complicated. SERVLET is powerful for writing business layers, but it is inconvenient for writing presentation layers. JSP is designed to facilitate the writing of the presentation layer. Of course, you can also write a business layer. Friends who are familiar with ASP, PHP, and CGI often unconsciously mix the presentation layer and business layer. Just like the previous friend who put the database processing information in JSP, in fact, it should be placed in the business layer.

According to SUN's recommendation, JSP should only store the content related to the presentation layer, that is, only the part of the HTML webpage is output. All data computing, data analysis, and database connection processes belong to the business layer and should be placed in java beans. Java beans are called through JSP to achieve integration of two layers.

In fact, Microsoft recently launched the DNA technology, simply put, ASP + COM/DCOM technology. Similar to JSP + BEANS, all presentation layers are completed by ASP, and all business layers are completed by COM/DCOM. Integration is achieved through calling.

Why are these component technologies used? The simple ASP/JSP language is very inefficient for execution. If a large number of users click, the pure SCRIPT language will soon reach the upper limit of its functions, the component technology can greatly increase the function ceiling and speed up the execution.

On the other hand, the pure SCRIPT language merges the presentation layer and business layer, resulting in inconvenient modification and the Code cannot be reused. If you want to modify a place, it usually involves more than a dozen pages of CODE. You only need to modify the component by using the component technology.

To sum up, SERVLET is an early imperfect product. It is very good to write business layers, and it is very smelly to write presentation layers, and the two layers are mixed. Therefore, JSP + BAEN is introduced, and presentation layer is written in JSP and business layer is written in BAEN. SUN also means replacing SERVLET with JSP in the future. However, this does not mean that learning SERVLET is useless. In fact, you should start with SERVLET, go to JSP, and then JSP + BEAN. It is emphasized that SERVLET and JSP are learned, and java bean is not used for integration. You need to make more effort on JSP + BEAN.

In addition, we can see that when ASP + COM and JSP + BEAN adopt the component technology, all components are compiled first, resident in the memory, and then run quickly. Therefore, the speed advantage of compilation of the SERVLET and JSP files that are often blown by the user in the memory is gone. On the contrary, ASP + COM + IIS + NT should be closely integrated, and there should be a great speed advantage. In addition, ASP + COM + IIS + NT development efficiency is very high, although there are many bugs. So why still use JSP + BEAN? Because JAVA has a bright future. After Microsoft split up, the operating system will be combined, and developers of application software must find a common development language for development. The time for JAVA to unite the world is now. If Microsoft splits smoothly, the application software company from the split will become a new leader in JAVA. At present, SUN and IBM, JAVA's big data, are both gloomy and disappointing. We hope the new company will inject new vigor into it. However, it is very likely that new companies will compete with old SUN in the JAVA standard war. The two sides will develop their own standards, affecting the JAVA exaggerated platform.

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

  1. JSP custom tags are explained in detail from the beginning to the end.
  2. How to configure and use fckeditor in JSP Environment
  3. Storage and display of images in databases Based on JSP
  4. Methods for constructing JSP and Javabean development and release Environments
  5. Examples of JSP + JavaBean + Servlet Working Principles

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.