Differences between jsp and servlet

Source: Internet
Author: User

Answer 1:

First, you must understand what servlet is. servlet is a java program executed on the server side, but it has a specific set of rules (that is, the api we usually call ); jsp is simply a servlet program written with another simple set of rules. It can write java code, html code, JavaScript, css, and so on ......, However, the server is first converted into a servlet program and then executed in the servlet execution order.

Answer 2:

The following information is obtained from the Internet:
What is the difference between JSP and SERVLET 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 a three-tier network structure, a network project can be divided into at least three layers: data layer, business layer, and 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 after learning JSP, java bean will not be used for integration, which means you will not learn it. You need to make more effort on JSP + BEAN.

In addition:

We can see that when ASP + COM and JSP + BEAN adopt component technology, all components are compiled first, resident in the memory, and then run quickly. Therefore, the speed advantage of the SERVLET/JSP that is often blown out after the memory is compiled first is no longer needed.
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.

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.