Web server (Apache) and servlet container (TOMCAT)

Source: Internet
Author: User

The relationship between Apache and Tomcat has been confusing before, and is now recorded here by querying information and understanding.

Apache and Tomcat

Locate both: Apache is an HTTP Web server, and Tomcat is a Web container.

There is a very figurative analogy: Apache is a car that can load static objects (HTML static Web pages, etc.), but can not install dynamic water (JSP, CGI, etc.), to fill the water needs barrels (containers), of course, the bucket can also not be placed in the car and stored separately, the container is tomcat.

The main differences between the two:

    • Apache is the world's most popular Web server (followed by Microsoft's IIS), can handle the browser's HTTP request, the default port is 80;tomcat is running on the Apache application server, to provide clients with a method that can be called. Tomcat is a servlet container (which can be considered an extension of Apache) and can be run independently.
    • Apache only supports static ordinary pages such as HTML, you can connect to tomcat one-way (Apache can access Tomcat's resources, otherwise); Tomcat is a servlet container that can support JSP, PHP, CGI, etc., where CGI is a public gateway interface. CGI scripts can be written in Perl.
    • Apache focuses on HTTP server;tomcat with a focus on the servlet engine.

The two can be consolidated: when the client needs to request a static resource, only the Apache server responds to the request, and when the client needs a dynamic resource, such as a JSP, the Tomcat service container (Tomcat can parse the JSP into a servlet) is required. Because JSP requires the database-driven interface of the JDK, the general combination is APACHE+TOMCAT+JDK.

Two introduction Apache service network better blog: Apache and tomcat different from the contact, Http://www.admin10000.com/document/974.html;web Server Apache architecture and principle,/HTTP Www.cnblogs.com/fnng/archive/2012/11/08/2761713.html.

servlet container (Tomcat)

Because the servlet does not have a main method, the invocation of the servlet life-cycle method is controlled by the container, which is the lifecycle of the container management servlet, including initialization (INIT), service invocation (services), and destruction (destroy). Tomcat is a servlet container.

When the Web server obtains a servlet request, it does not submit the request directly to the servlet, but instead to the Web container (TOMCAT) that deploys the servlet, which provides the HTTP request and response to the servlet by the container and invokes the servlet's method by the container , such as Doget () and Dopost (). A more detailed container handles the request and response process, which is then collated.

Web server (Apache) and servlet container (TOMCAT)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.