Applications in JVM, Tomcat, Servlet, and Tomcat. Thoroughly understand the connection between this concept, jvmtomcat

Source: Internet
Author: User

Applications in JVM, Tomcat, Servlet, and Tomcat. Thoroughly understand the connection between this concept, jvmtomcat

The applications in tomcat and tomcat (the war package in webapps) run in the same jvm, but the division of labor is different.

The role of tomcat is "dispatcher", and the role of your application is "worker". tomcat processes a requestRoughThe process is as follows:
1. Assume that tomcat listens to port 8080. When an http request is sent from port 8080 of the host, tomcat is first informed.
2. tomcat adds this request to a queue as a task. Several worker threads in the jvm obtain the task from this queue.
3. assuming that worker thread A obtains the task, thread A checks the loaded web by analyzing the request url. xml configuration to determine which servlet the request should be sent to the application for processing (assuming that the application is implemented using servlet)
4. Working thread A calls the corresponding servlet method (service/get/post, etc.), encapsulates the request as A request object and passes it to the servlet
5. At this time, the application starts to work (in fact, the work is still a working thread, but the business logic written in the application is executed), parse request parameters, process business processes, and generate response
6. Worker thread A sends response back to the sending end of the request.

 

The servlet specification regulates the communication between applications and containers. To put it simply, for example, if you use SpringMVC to write a web application, springmvc complies with servlet specifications, so it can run on any container that complies with servlet specifications. For example, it can run on tomcat. tomcat is a servlet container. Of course, it can also run on jetty.

Tomcat is developed in java. Therefore, tomcat is a java application and needs to be run in JVM, that is, a java virtual machine.

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.