First of all, I am not the title party. This is purely my personal opinion, do not spray.
Let's talk about how JSP came into being.
In the early web, JS,CSS is far from mature, the technical direction is not clear! Due to the lack of front-end language, large companies have launched a backend-based template language. such as jsp,asp,php and so on.
These background-based template languages lead an era!
For example, in JSP, built-in basic data object, plus custom tag, can achieve "semi-component" development, which greatly accelerated the development speed of the system.
But in these server template languages, there are some unspoken pain points for JSP alone:
1. Page Cannot save data
In addition to saving data in a Web page, there is no place to save the data. For example, the current login user, for the page calculation of auxiliary data and so on.
Have done JSP know, everywhere use input[type= "hidden" to store data, on the one hand cause the page HTML is larger and slower rendering.
On the other hand, the code is free from the architecture, and sooner or later it will avalanche, dikes destroyed in the nest!
2. Complete black box operation
The JSP will eventually be compiled into a class file run, it's running mechanism completely black box. How many times, JSP error, can only rely on "guess" to solve the problem.
Another problem with black boxes is that they cannot be run alone. For example, a form, want to send to the user as a message, JSP can not be implemented, can only be rewritten with HTML again. It's unbearable!
So many companies are paired with Freemarker, or jasperreport use, to separate printing and other functions. This requires employees to have more technical pressure, do not think this is a good thing, this is the operating cost!
3. Too coarse grain size
How to understand the granularity is too coarse? For example, there is a page that wants to be reused, or some HTML in the page wants to be reused! Because JSP and background data strictly correspondence, and JSP can not be separated, impossible to do.
In development, if you do not have the least granularity of reuse, you will be lost in the ocean of copy and paste.
If you do not think copy and paste have any problem, can only indicate that you still stay at the level of the code farm.
Based on the above, many people abandoned the JSP, to the freemarker,velocity and other separate template language!
These languages have been improved to the disadvantage of JSP. Take Freemarker for a while.
1. Can be run alone, meaning users can reuse pages. For example, the above-mentioned form sends a message, you can use Freemarker to generate HTML directly, instead of having to write another one.
2. Smaller-grained component macros, which are slightly more flexible than JSPs.
Freemarker,velocity as the background template language, they still do not solve some of the core issues. For example, the page cannot store frequently used data and cannot run away from the background.
But they are increasingly popular as tools for generating reports, format printing, and mail templates.
With Freemarker printing, more than one order of magnitude is lighter than jasperreport printing.
But they can only be used as the transition product of JSP, and some special usage, as the page logical display, also the more arduous.
The Times in the development, technology is ever-changing!
background-based template language, always put the "front" in a "secondary" position, it has been in order to do the "main" and struggle ...
With the development of the web, JS is stable and popular, and finally the template language based on JS appears.
For example, simple refining of the underscore Template,mustache, support for custom label handlebars and so on.
JS-based template can be more granular definition, run based on JS, the relevant data directly stored in JS, easy to use.
JS templates can be run based on any JS engine, so the issue of printing and sending mail can be implemented without the use of other tools, reducing the technical pressure on developers.
The current Popular Front-end MVC framework, such as Backbone,angularjs,reactjs ... And so on, are all based on the template to run. With the continuous development of the Web, JS templates will eventually become mainstream.
And already old JSP, obviously has not been keeping up with the pace of the times, will eventually fade away ...
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The big waves, the JSP will eventually die