This is a problem I encountered when I reviewed web programming at the end of today and other problems subsequently exploded. Although I am only familiar with these Java and JSP languages, however, the question is just self-explanatory. There may be a lot of errors, and the time is limited. We need to complete the test report. Put it here first, and wait until we find the answer before making a correction. If you have any friends who know this knowledge, you may wish to seek advice. Thank you!
The meta question comes from the comparison between JSP and servlet.
We know that servlet can enable Java code to run on a client browser like applet, And it will run on an application server under your control. Without any background knowledge, this is a rule by default, that is, servlet is developed in this way. In practical applications, when we request a JSP page, JSP is first converted to servlet, then compiled, executed, and finally returned to the browser.
Question 1: So now that we have JSP and Servlet, why do we need to get them for comparison? Is it wrong for me to "have JSP first and then servlet?
I think:
Not necessarily only JSP is available before servlet is available, because JSP only encapsulates Java language and JSP tag in HTML. Servlet encapsulates JSP tags and HTML tags in Java. Therefore, they are equal. We can directly write servlet, of course we can also directly write JSP Luo.
Question 2:Why should I submit JSP to the server for processing first?
I think:
1. Because JSP is a script language embedded with Java code on the server side, Java code cannot be compiled, executed, and then run without JVM. Therefore, you must give this step to the server that can process the Java code for processing.
2. the JSP page contains JSP tags, Java code, and HTML code. The JSP tag and Java code cannot be interpreted and executed by the browser. Therefore, it must be converted into code that the browser can understand by some means.
Question 3: Just give the JSP page to the server for processing, but why not convert it into a servlet instead of directly processing it?
I think:
The JSP page contains JSP tags, Java code, and HTML code. Our goal is to get the code that the browser can understand. To make them uniform, we must convert them into a consistent format, that is, Servlet, another language.
A new problem:
What code does the browser understand? I made the following ideas:
At the beginning, the browser can only understand HTML. As time passes, people's requirements for Web pages gradually become higher. In the past, static pages gradually transitioned to dynamic pages. Therefore, browsers have to work hard to undertake more arduous translation tasks. So we began to support VBScript, JavaScript, and other scripting languages. And because we need to support dynamic page effects such as flash, we must need some additional controls.