Differences and connections between apache and tomcat

foreword

I have used Tomcat and Baidu tomcat in my work. When you enter the Tomcat official website, you can see the following interface.
write picture description here
I thought Tomcat was Apache, but today I suddenly found out that these are two things, 囧.

1. Apache supports static pages, and tomcat supports dynamic ones, such as servlets.

Generally, if apache+tomcat is used, apache is only used as a forwarder, and the processing of jsp is handled by tomcat. Apache can support php\cgi\perl, but if you want to use java, you need tomcat to support in the apache background, and the java request is forwarded by apache to tomcat for processing.

Apache is a web server, Tomcat is an application (java) server, it is just a servlet (jsp is also translated into servlet) container, which can be considered as an extension of apache, but can run independently of apache.

2. APACHE is a web server environment program

Enabled it can be used as a web server, but only supports static web pages. Such as (asp, php, cgi, jsp) and other dynamic web pages will not work. If you want to run jsp in the APACHE environment, you need an interpreter to execute the jsp web page, and this jsp interpreter is TOMCAT. But why do you need JDK, that is because jsp needs to connect to the database, it needs jdk to provide the driver to connect to the database, so APACHE+TOMCAT+JDK is needed to run the web server platform of jsp.
The advantages of integration are: if the client requests a static page, only the Apache server needs to respond to the request; if the client requests a dynamic page, the Tomcat server responds to the request; because jsp is the server-side interpreted code, so integration can be reduced Tomcat's service overhead.

3. Different focus

apache: focuses on http server;
tomcat: focuses on servlet engine. If it runs in standalone mode, it is functionally equivalent to apache and supports JSP, but it is not ideal for static web pages.

4. Apache and Tomcat have the following similarities and differences:

Same point:

1. Both are developed by apache organization

2. Both have the function of HTTP service

3. Both are free

Differences:
Apache is dedicated to providing HTTP services and related configurations (such as virtual hosts, URL forwarding, etc.).
Tomcat is a JSP server developed by the Apache organization under the J2EE-compliant JSP and Servlet standards.

All in all, apache is a web server, and tomcat is an application (java) server. It is just a servlet (jsp is also translated into servlet) container, which can be considered as an extension of apache, but can run independently of apache. In other words, apache is a truck that can hold things like html and so on. But it cannot hold water. To hold water, you must have a container (bucket), and this bucket may not be placed on the truck.

At the end of the article, there is a post on Zhihu, and the great gods from all walks of life answered wonderfully:
https://www.zhihu.com/question/32212996

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324909736&siteId=291194637