Servlet technology

xiaoxiao2021-03-06  61

First, the servlet servlet is a server-side program written in Java, calls and executes any Java classes executed by the server side. Servlet is a Java program that uses Java Servlet Application Interface (API) and related classes and methods. The browser is also a Java program running on the client called Applet, and the Java program running on the server is called a servlet.

Second, the main function of servlet

The main feature of the servlet is interactively browsing and modifying the data generation dynamic web content. The process is: 1, the client sends a request to the server side. 2, the server sends the request information to the servlet. 3. The servlet generates the response content and passes it to the server. 4. The server returns the response to the client.

Third, servlet can complete the same function as CGI

Servlet provides all the advantages of Java applications: - Migramid, steady, easy development. 1. The main advantage of servlet is that a servlet is activated by the first request sent by the client, and then continues to run in the background, waiting for future request. Each request will generate a thread instead of a completed process. Multiple customers can get services at the same time. Generally, the servlet process is only detached when the web server is uninstalled. 2, Servlet and CGI comparison: ◆ Java servlet technology is more efficient than traditional CGI technology. Traditional CGI has a new process for each HTTP request; for Java Servlet, on the Java virtual machine, each request responds by a Java thread thread instead of an operating system process. ◆ Java servlet technology is powerful than traditional CGI technology. The Java Servlet can easily handle HTML form data, and can also read and set HTTP header information, and can process cookies, track other mass functions such as sessions. ◆ Servlet is modular. Each servlet can perform a specific task and you can work together. ◆ Can share data between Java servlets. It can easily implement management from Request to Request, simplify session and get the previous page. ◆ Java servlet technology is much shorter than traditional CGI technology call times. The CGI program is running as a separate process, usually the call time is longer; and the servlet in the memory can be loaded very quickly. ◆ Java servlet technology is more secure than traditional CGI technology. Java defines a complete security mechanism, including SSI, CA certification, and security policies. ◆ Java servlet technology has all the advantages of Java technology. Servlet is written in Java, servlet has almost all advantages of Java technology, such as portability, robustness, and easy-to-development, easy maintenance.

Fourth, the relationship between servlet and JSP

1. JSP technology is mainly used to express page, while servlet technology is mainly used to complete a large number of logical processing. 2, JSP is mainly used to send users to the front end, while servlet mainly responds to the user's request, complete the logical processing of the request. ◆ In actual development, the JSP page is often developed, and then the JSP code is converted into a servlet. Benefits: Take advantage of JSP's page performance to avoid serious shortage of servlet page performance, greatly shortening the development cycle.

V. Servlet application

Servlet Application: ◆ Hand HTTP request. ◆ It is used to handle the HTML form. ◆ Allows cooperation between people. ◆ Transfer request. ◆ Allows the definition activation agent.

Sixth, the life cycle of servlet

转载请注明原文地址:https://www.9cbs.com/read-119457.html

New Post(0)