Home Java javaTutorial Why was jsp eliminated?

Why was jsp eliminated?

May 11, 2019 am 11:05 AM
java jsp

Most of the previous projects were Java programmers who were both father and mother, working on front-end (ajax/jquery/js/html/css, etc.) and back-end (java/mysql/Oracle, etc.) .

With the development of the times, many large, medium and small companies have gradually begun to distinguish the boundaries between the front and back ends more and more clearly. Front-end engineers are only responsible for front-end things, and back-end engineers are only responsible for back-end things. As the saying goes, there are Specialization, if a person knows everything, then he is not good at anything after all.

Recommended course: Java Tutorial.

Why was jsp eliminated?

Large and medium-sized companies need professionals, and small companies need generalists. But for personal career development, I suggest they be separated. If you are just going to eat Java for the rest of your life, don't study CSS, JS, etc.

Focus your energy on java, jvm principles, spring principles, mysql locks, transactions, multi-threading, large concurrency, distributed architecture, microservices, and related project management, etc., so that your core Competitiveness will become higher and higher. As the saying goes, what you invest in life will be what life will give you back.

(Full of positive energy:

Once you become an elite in the industry, believe me, when the time comes, cars, houses, women, money, and opportunities will all come to you. , don’t worry, really.

It’s really simple to be a Java programmer. The more knowledge you have, the more money you will make. Of course, you also need to have a certain amount of emotional intelligence...

The stronger your ability, the more value you create than others. You create value for the company, and the company gives you various benefits, a win-win situation!)

Once upon a time, Our java web projects all use several backend frameworks, springmvc/struts spring spring jdbc/hibernate/mybatis, etc.

Most projects are divided into three layers in the java backend, the control layer (controller/ action), business layer (service/manage), persistence layer (dao).

The control layer is responsible for receiving parameters, calling relevant business layers, encapsulating data, and routing to jsp pages. Then use various tags (jstl/el) or handwritten java (<%=%>) on the jsp page to display the background data.

Right?

Let’s look at this situation first. The requirements have been determined, the code has been written, and the tests have been completed. What next? Is it about to be released?

You need to use maven or eclipse and other tools to package your code into a war package, and then publish this war package to the web container in your production environment (tomcat/jboss/weblogic/websphere/jetty/ resin), right?

After publishing, you need to start your web container and start providing services. At this time, you can access your website by configuring the domain name, dns, etc. (assuming you are a website).

Let’s see, are all your front-end and back-end codes in that war package? Including your js, css, pictures, and various third-party libraries, right?

Okay, let’s enter your website domain name (www.xxx.com) in the browser. What happens after that? (This question is also an interview question in many companies)

I just picked it up and said, please search for children's shoes with poor foundation.

The browser routes to your service through IP. After the TCP three-way handshake, it starts accessing your web server through the TCP protocol. After your web server gets the request, it starts to provide services, receives the request, and then passes response returns your response to the browser.

So let’s take a look. Let’s first assume that your homepage has 100 pictures and a single-table query. At this time, the user’s seemingly one HTTP request is actually not one. The user first During the first visit, there will be no cache in the browser. For your 100 pictures, the browser will request 100 http requests in succession (someone will tell me about the problem of long and short http links, which will not be discussed here). Your When the web server receives these requests, it needs to consume memory to create a socket for TCP transmission.

Here’s the important point. In this case, the pressure on your web server will be very high, because all requests in the page are only requested to your server. If there is only one person, it will be fine. If there are 10,000 people concurrently As for access (let’s not talk about web server clusters, let’s talk about single-instance web servers), how many TCP links can your server handle? How much memory does your server have? How many IOs can you withstand? How much memory have you allocated to the web server? Will it be down?

This is why, the larger and medium-sized web applications are, the more they need to be decoupled.

Theoretically, you can put your database, application service, message queue, cache, user uploaded files, logs, etc. on one host, but this is like putting all your eggs in one basket, and there are hidden dangers. Very big.

Normal distributed architecture must be disassembled, your application server cluster (front, back) file server cluster, database server cluster, message queue cluster, cache cluster, etc.

Let’s get down to business. First of all, we should try to avoid using jsp in future java web projects, decouple the front and backends, and play with distributed architecture, so that our application architecture will be stronger.

Pain points of using jsp:

1. Dynamic resources and static resources are all coupled together, and true dynamic and static separation cannot be achieved. The server is under great pressure because the server will receive various http requests, such as css http requests, js, pictures, dynamic codes, etc. Once there is a problem with the server, the front and backends will be played together, and the user experience will be extremely poor.

2. After the front-end engineer completes the html, a java engineer needs to modify the html into a jsp page. The error rate is high (because a large number of js codes often appear in the page), and both parties need to collaborate when modifying the problem. Development, inefficiency.

3.jsp must be run in a web server that supports Java (such as tomcat, etc.), and nginx cannot be used (nginx is said to have up to 50,000 single-instance http concurrency, this advantage must be used), and the performance cannot be improved. .

4. The first time you request jsp, it must be compiled into a servlet in the web server. The first run will be slower.

5. Every time you request jsp, you access the servlet and then use the output stream to output the html page, which is not as efficient as using html directly.

6.jsp contains many tags and expressions. Front-end engineers will be stretched when modifying the page and encounter many pain points.

7. If there is a lot of content in jsp, the page response will be very slow because it is loaded synchronously.

Based on some of the above pain points, we should move the development weight of the entire project forward to achieve true decoupling of the front and back ends!

The old way was:

1. Client request
2. Server-side servlet or controller receives the request (routing rules are formulated by the backend, and most of the weight of the entire project development In the backend)
3. Call service, dao code to complete business logic
4. Return jsp
5.jsp displays some dynamic code

The new way is:

1. The browser sends a request
2. Directly reaches the html page (routing rules are formulated by the front end, and the weight of the entire project development is moved forward)
3. The html page is responsible for calling the server interface to generate data (through ajax, etc. etc.)
4. Fill in html to show dynamic effects.

(Interested children can visit large websites such as Alibaba, and then press F12 to monitor how http works when you refresh the page. Most of them request background data separately. Use json transmits data instead of a large and comprehensive http request to return the entire page including movement)

The benefits of this are:

1. It can achieve true front-end and back-end decoupling , the front-end server uses nginx.

The front-end server places a series of static resources such as css, js, pictures, etc. (You can even put css, js, pictures and other resources into a specific file server, such as Alibaba Cloud's oss, and use cdn Acceleration), the front-end server is responsible for controlling page references, jumps, and calling back-end interfaces. The back-end server uses tomcat.

(You need to use some front-end engineering frameworks such as nodejs, react, router, react, redux, webpack)

2. If you find a bug, you can quickly locate the problem. No There is a phenomenon of kicking the ball at each other.

Page logic, jump errors, browser compatibility issues, script errors, page styles and other issues are all the responsibility of front-end engineers.

Interface data errors, data not submitted successfully, response timeout and other problems are all solved by back-end engineers.

Both parties do not interfere with each other. The front-end and back-end are a family that loves each other.

3. In the case of large concurrency, I can horizontally expand the front-end and back-end servers at the same time. For example, a homepage of Taobao requires 2,000 front-end servers to be clustered to withstand the average daily PV of billions.

(I went to Alibaba’s technology summit and heard them say that all their web containers are written by themselves. Even if a single instance can withstand 100,000 http concurrency, 2,000 units can withstand 200 million http concurrency, and they can also use It’s scary to predict that the peak will come and expand infinitely, just one homepage...)

4. Reduce the concurrency pressure on the back-end server, and transfer all http requests except the interface to the front-end nginx.

5. Even if the back-end service temporarily times out or is down, the front-end page will be accessed normally, but the data cannot be refreshed.

6. Maybe you also need to have a light application related to WeChat, so that your interfaces can be shared. If there are also app-related services, you can also reuse a large number of interfaces through some code reconstruction to improve efficiency.

7. No matter how many things are displayed on the page, you are not afraid because it is loaded asynchronously.

Note:

1. When holding a requirements meeting, all front-end and back-end engineers must participate, and interface documents need to be formulated. Back-end engineers must write test cases and do not let front-end engineers To act as a full-time tester for your team, it is recommended to use the

chrome plug-in postman, and the service layer test cases are written with junit.

2. The above interface is not the interface in java. To put it bluntly, calling the interface means calling the method in your controller.

3. Increases the workload of the front-end team, reduces the workload of the back-end team, and improves performance and scalability.

4. We need some front-end frameworks to solve functions such as page nesting, paging, and page jump control. (Those front-end frameworks mentioned above).

5. If your project is very small, or a simple intranet project, then you can rest assured that it does not require any architecture, but if your project is an external network project, hahaha.

6. In the past, some people used template frameworks such as velocity/freemarker to generate static pages, but now this practice has been eliminated.

The main purpose of this article is to say that jsp has been eliminated in large-scale external java web projects, but it does not say that jsp can be completely ignored. For some student friends, jsp/servlet, etc. The relevant java web basics still need to be firmly grasped. Otherwise, what do you think the springmvc framework is based on?

The above is the detailed content of Why was jsp eliminated?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1252
29
C# Tutorial
1226
24
Break or return from Java 8 stream forEach? Break or return from Java 8 stream forEach? Feb 07, 2025 pm 12:09 PM

Java 8 introduces the Stream API, providing a powerful and expressive way to process data collections. However, a common question when using Stream is: How to break or return from a forEach operation? Traditional loops allow for early interruption or return, but Stream's forEach method does not directly support this method. This article will explain the reasons and explore alternative methods for implementing premature termination in Stream processing systems. Further reading: Java Stream API improvements Understand Stream forEach The forEach method is a terminal operation that performs one operation on each element in the Stream. Its design intention is

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP vs. Other Languages: A Comparison PHP vs. Other Languages: A Comparison Apr 13, 2025 am 12:19 AM

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP vs. Python: Core Features and Functionality PHP vs. Python: Core Features and Functionality Apr 13, 2025 am 12:16 AM

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.

Java Program to Find the Volume of Capsule Java Program to Find the Volume of Capsule Feb 07, 2025 am 11:37 AM

Capsules are three-dimensional geometric figures, composed of a cylinder and a hemisphere at both ends. The volume of the capsule can be calculated by adding the volume of the cylinder and the volume of the hemisphere at both ends. This tutorial will discuss how to calculate the volume of a given capsule in Java using different methods. Capsule volume formula The formula for capsule volume is as follows: Capsule volume = Cylindrical volume Volume Two hemisphere volume in, r: The radius of the hemisphere. h: The height of the cylinder (excluding the hemisphere). Example 1 enter Radius = 5 units Height = 10 units Output Volume = 1570.8 cubic units explain Calculate volume using formula: Volume = π × r2 × h (4

PHP's Impact: Web Development and Beyond PHP's Impact: Web Development and Beyond Apr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP: The Foundation of Many Websites PHP: The Foundation of Many Websites Apr 13, 2025 am 12:07 AM

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.

See all articles