Reply content:
If only to develop a Web page, the development of the completion of their own browser can be previewed, that with no Apache relationship is not big. But the development of multiple Web pages, if you want to let others also see the effect of what, at this time, you will send these Web files (HTML files) to these people, or to set up an environment, to provide a URL for others OK?
In this environment, you will use a web Server such as Apache and IIS.
And more sometimes, you need to deal with some dynamic resources, at this time, directly send the source file does not let people see the actual effect, often this time in addition to Apache this web Server, but also need to be able to parse a specific language container, such as JSP, servlet corresponding Tomcat.
When dynamic static resources are able to respond, the effects of your files are displayed.
Here, I also wrote some of the differences between Web server and Web container in the public number:
So you will often see the question question: What is the difference between Tomcat and Apache ?
What difference does it have?
There is a uniform salutation to the role of Tomcat: Web container (Web Container). Similar web containers are jetty, resin, and so on.
Why is it called a container?
Because in the software field, this kind of management to deal with the life cycle of things, are called containers . Tomcat here is responsible for the entire servlet lifecycle (LifeCycle), including when to create a servlet, when to initialize some internal resources, what to do when the request is processed, when to destroy, and so on. Just like a big parent. So, you will often hear that the IOC of spring is implemented through the IOC container, because it also manages the life cycle of the entire spring bean.
What does Apache do?
Like Apache, there is a type of salutation called a Web server. This kind of brother, they can only handle the HTTP protocol, such as when we request HTML, images and other static resources, can be done through the Web server. But if the request is jsp,php, and so on, these times, the Web server is powerless, can only transfer the request to the appropriate person to handle, if the request JSP or servlet, then the appropriate person is the above Web container. Similar web servers have Apache, IIS, Nginx and so on.
So, in summary, the difference between the two is that Tomcat can be used not only to handle dynamic resources, to handle servlets, JSPs, but also to handle static resources, while Apache can only handle static resources. The variant of this interview question is what is the difference between Web container and Web server, and I'm sure you already know the answer.
This time, you will say, that tomcat this boy can all dry, but also to Apache why?
Ah, this kid at that time to learn a lot, but also very good, but to deal with static resources this matter, did not learn special fine. It's like saying that tailors may cook for themselves, but they are not as professional as cooks.
so when dealing with static resources, a Web Server such as Apache can be configured in front of Tomcat, not only to handle static resources efficiently, but also to cache these commonly used static resources and even to achieve load balancing (which, of course, requires a later web container do cluster).
Welcome attention.