Home > Java > javaTutorial > What does jsp compilation generate?

What does jsp compilation generate?

(*-*)浩
Release: 2019-05-29 11:16:31
Original
3471 people have browsed it

Each JSP page will be compiled by the web container into a Java class for the web container to call, and an HTML page will be generated and fed back to the user. Understanding the mutation methods and rules is very beneficial for us to learn JSP. It can be said that after learning this compilation principle, we have learned most of the JSP knowledge, and the remaining work is just to memorize some. tablib and use it repeatedly to make yourself more proficient

What does jsp compilation generate?

JSP will be compiled into .java and placed in Tomcat/work/Catalina/localhost/***/org /apache/jsp/page
is then compiled into .class

jsp = java + html
servlet = java + out.print(html)
Copy after login

1. The client sends a request to the web container

2. The web container first translates jsp into a servlet Source code
3. The web container compiles the servlet source code into a .class file
4. The web container executes the .class file
5. The web container responds to the client with the result

JSP is A scripting language that packages the interface of the Java Servlet system, simplifying the use of Java and Servlets, and at the same time provides the ability to dynamically execute web pages by extending JSP tags (TAG). Despite this, JSP still does not exceed the scope of Java and Servlet. Not only can Java code be written directly on the JSP page, but JSP is first translated into Servlet before it is actually run. JSP is executed on the server and the execution results are output to the client browser. We can say that it is basically browser-independent. It is different from JavaScript, which is a client-side scripting language that is executed on the client and has nothing to do with the server.

A servlet can be thought of as a server-side applet. Servlets are loaded and executed by the web server just like applets are loaded and executed by the browser. A servlet receives a request from a client (via a web server), performs some kind of job, and returns the results.

The basic process of using servlet is as follows:
·The client makes a request through HTTP.
·The Web server receives the request and sends it to the servlet. If the servlet has not been loaded, the Web server will load it into the Java virtual machine and execute it.
·The servlet will receive the HTTP request and perform some processing.
·The servlet will return a response to the Web server.
·The Web server sends the response received from the servlet to the client.

Since the servlet is executed on the server, security issues usually associated with applets do not need to be implemented. It is important to note that web browsers do not communicate directly with servlets; servlets are loaded and executed by the web server.
And servlets are written in Java, so they are platform independent from the beginning. In this way, the promise that Java can be written once and run anywhere can also be realized on the server.

Servlets also have some unique advantages that CGI scripts do not have:
Servlets are persistent. servlets only need to be loaded once by the web server and can remain serviced between requests (such as a database connection). In contrast, CGI scripts are ephemeral and transient. Each request for a CGI script causes the web server to load and execute the script. Once the CGI script has finished running, it is cleared from memory and the results are returned to the client. Each use of a CGI script will cause the program initialization process (such as connecting to a database) to be repeatedly executed.

Servlet is platform independent. As mentioned before, servlet is written in Java, and it naturally inherits Java's platform independence.

Servlet is extensible. Since servlet is written in Java, it has all the advantages that Java can bring. Java is a robust, object-oriented programming language that is easily extensible to suit your needs. Servlets naturally also have these characteristics.

Servlet is safe. The only way to call a servlet from the outside world is through a Web server. This provides a high level of security, especially if your web server is protected by a firewall.

The above is the detailed content of What does jsp compilation generate?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template