Home  >  Article  >  Web Front-end  >  The difference and connection between servlet and jsp

The difference and connection between servlet and jsp

一个新手
一个新手Original
2017-10-19 10:26:307010browse


What is servlet:

(1) Servlet is a server-side Java application that is independent of platform and protocol and can generate dynamic Web pages. .
(2) It acts as the middle layer between client requests (web browsers or other HTTP client programs) and server responses (databases or applications on HTTP servers).

What is jsp:

(1) The full name of JSP is Java Server Pages, and the Chinese name is java server page. It is basically a simplified Servlet design. It [1] was developed by Sun A dynamic web technology standard initiated by Microsystems and established by many companies.

The connection between servlet and jsp:

(1) jsp is an advanced encapsulation of servlet. The essence is still servlet.
When the jsp page is loaded for the first time, a java file will be generated, compiled into a .class file in the virtual machine, and finally loaded and initialized into a servlet.
The difference and connection between servlet and jsp

The common points and differences between servlet and jsp:

(1) servlet dynamically generates an html page through httpservletresponse in java code
(2 ) jsp generates a dynamic html page by embedding java code into html
(one is to write html in java, the other is to write java code in html)

jsp and servlet appear Meaning:

(1) When we use servlet to generate dynamic pages, it will be very complicated. Because you need to write html statements in out.println(). But servlets are particularly good at handling front-end and back-end data interaction.
(2) Therefore, at this time we introduce jsp technology to replace the function of servlet to generate html. Let serlvet only focus on the interaction between the front-end page and the background data. This also implements the idea of ​​​​mvc.


The above is the detailed content of The difference and connection between servlet and jsp. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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