First, the Tomcat directory structure
1. Bin: Store script file. One of these files is Catalina.bat, which opens the configuration file and configures the Tomcat environment after the non-comment line is added to the JDK path (SET java_home=c:\j2sdk1.4.2_06).
2. conf: Store different configuration files (e.g. Server.xml and Web. xml)
1) server.xml File:
-
-
- This file is used to configure and server-related information, such as the port number that Tomcat initiates, the configuration host host, Configure Context
- A resource that cannot be dynamically reloaded, the server must be restarted if modified
- each <Context> element represents a single Web application running on a virtual host
- One tomcat can start multiple apps at the same time
2) Web. xml file:
-
-
- Global Web. XML, be sure to
- Some default servlets are described in the file, which is called when each webapp is deployed, and the default servlet for the Web app is configured.
3) Tomcat-users.xml file: Configure user passwords and permissions for Tomcat
4) Context.xml:
-
-
- Defines the default behavior for Web apps, such as the XML path (which appears after Tomcat5.5, the <Context> element in the host that was previously reflected in/conf/server.xml)
- will be scanned by Tomcat at regular intervals, once found to be repaired
3. lib: The library file (jars) to store the Tomcat operation;
4, logs: Storage of Tomcat execution log file;
5. Temp:
6. Webapps:tomcat's main Web publishing directory (including application examples)
7, work: Store JSP compiled after the class file generated
Add
1. Web App Personalization: WebApp under/meta-inf/context.xml and/web-inf/web.xml
second, tomcat boot mode : Launched via plug-in in Eclipse, through a batch file Startup.bat or startup.sh in Tomcat
Third, Tomcat Boot Process
1.
2
Iv. the TOMCAT server process for processing an HTTP request
Suppose the request from the customer is: http://localhost:8080/wsota/wsota_index.jsp
1. The request is sent to the native port 8080, which is obtained by the Coyote http/1.1 connector that is listening there. The main task of connector is to receive the browser's incoming TCP connection request and create a request and response object for each
The data is then generated by a thread that processes the request and passes the resulting request and response object to the thread that is processing it
2. Connector the request to the engine of the service it is working on, and waits for a response from the engine
3, the engine obtains the request localhost/wsota/wsota_index.jsp, matches all the virtual host hosts which it owns
4. The engine matches the host named localhost (even if it does not match the request to the host processing, because the host is defined as the engine's default host)
5. LocalHost host gets the request/wsota/wsota_index.jsp, matching all the context it owns
6, host match to the context of the path is/wsota (if the match is not the request to the path named "" context to deal with)
7, path= "/wsota" the context to obtain the request/wsota_index.jsp, in its mapping table to find the corresponding servlet
8. Context matches to a servlet with a URL pattern of *.jsp, corresponding to the Jspservlet class
9, constructs the HttpServletRequest object and the HttpServletResponse object, calls the Jspservlet Doget or Dopost method as the parameter
10. The context returns the HttpServletResponse object to host after the execution has finished
11. host returns the HttpServletResponse object to the engine
12, engine to return the HttpServletResponse object to connector
13, connector the HttpServletResponse object back to the customer browser
Reference: https://www.cnblogs.com/crazylqy/p/4706223.html
Java Web Tomcat Server