Tomcat directory structure | JD Cloud Technical Team

The Tomcat directory structure diagram is as follows:

1. bin directory

Store some executable binary files. Those ending with ****.sh are commands executed under Linux, and those ending with ****.bat are commands executed under Windows.

2. conf directory

Stores tomcat related configuration files.

2.1、catalina.policy

Project security files are used to prevent deceptive code or JSP from executing commands like System.exit(0), which may affect the destruction of the container. This file will only be used when Tomcat is started with the -security command line parameter, that is, when starting tomcat, startup.sh -security .

2.2、catalina.proterties

Configure tomcat startup related information files

2.3、context.xml

Monitor and load resource files. When the monitored files change, they will be automatically loaded and usually not configured.

2.4、jaspic-providers.xml和jaspic-providers.xsd

Rarely used files

2.5、logging.properties

Tomcat log file configuration, including output format, log level, etc.

2.6、server.xml

Core configuration file: modify port number, add encoding format, etc.

Introduction to core components:

<1>Server: The top-level element, and the only one, represents the entire tomcat container. A Server element contains one or more Service elements;

<2>Service: Provides services to external parties. A Service element contains multiple Connector elements, but can only contain one Engine element;

<3>Connector: Receive the connection request, create Request and Response objects to exchange data with the requesting end; then allocate threads for Engine to process the request, and pass the generated Request and Response objects to Engine

<4>Engine: There is only one Engine component in the Service component; Engine is the request processing component in the Service component. The Engine component receives and processes requests from one or more Connectors, and returns the completed response to the Connector, and ultimately to the client.

<5>Host: represents a specific virtual host.

<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">

**name:** The host name of the virtual host. For example, localhost represents the name of the local machine. In actual application, the specific domain name should be filled in, such as www.dog.com . Of course, if the virtual host is accessed by internal personnel, the IP address of the server can also be filled in directly, such as 192.168.1.101;

**appBase:** Sets the path to the web application group. The value of the appBase attribute can be a relative path relative to the Tomcat installation directory, or an absolute path. It should be noted that the path must be accessible to Tomcat;

**unpackWARs:** Whether to automatically expand the war compressed package before running the web application, the default value is true;

**autoDeplay:** Whether to allow automatic deployment, the default value is true, which means that Tomcat will automatically detect file changes under the appBase directory and automatically apply them to running web applications;

**deployOnStartup: When ** is true, it means that Tomcat checks web applications when starting, and all detected web applications are regarded as new applications;

<6>Context: This element represents a web application running on a specific virtual host. It is a sub-container of the Host. Each Host container can define multiple Context elements. Used when deploying web applications statically.

<Context path="/" docBase="E:\Resource\test.war" reloadable="true"/>

**path:** The path name when accessed by the browser. The path attribute can only be set when automatic deployment is completely turned off (deployOnStartup and autoDeploy are both false) or docBase is not in appBase.

**docBase:** When deploying statically, docBase can be in the appBase directory or not; in this example, it is not in the appBase directory.

**reloadable:** When the setting item is changed, reload the item.

2.7、tomcat-users.xml和tomcat-users.xsd

tomcat-users.xml: tomcat user configuration file, configure user name, password, user has permissions

Tomcat does not configure any users by default. Only after configuring users can you use the following three functions of Tomcat Manager:

<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>
<user username="admin" password="123456" roles="manager-script"/>

tomcat-users.xsd: Description and constraints on the tomcat-users.xml file

2.8、web.xml

Common configuration related to web applications can do the following things.

  • Configure servlet
  • Add filters, such as filtering sensitive words
  • Set session expiration time, tomcat defaults to 30 minutes

  • There are a lot of MIME types registered, namely document types. These MIME types are used to describe the document type between the client and the server. If the user requests an html web page, the server will also tell the client that the response document from the browser is of text/html type. This is a MIME type.
  • Configure the system welcome page

3. lib directory

Store tomcat dependent jar packages.

Among them, ecj-xxxjar plays the role of compiling .java files into .class bytecode files.

4. logs directory

Store the log files generated when tomcat is running.

In the Windows environment, the log file is output to the catalina.xxxx-xx-xx.log file.

In the Linux environment, the log file is output to the catalina.out file.

Generally there are the following categories:

catalina.xxxx-xx-xx.log Log file output content under windows
host-manager.xxxx-xx-xx.log Access the host-manager project log under webapps
localhost.xxxx-xx-xx.log When tomcat starts, it accesses the service by itself and only records tomcat access logs, not business project logs.
localhost_access_log.xxxx-xx-xx.txt Indicates access to all project log records under tomcat
manager.xxxx-xx-xx.log Access the manager project log under webapps

5.temp directory

Users store temporary files generated during the operation of tomcat (clearing them will not affect the operation of tomcat).

6. webapps directory

Used to store applications, and can publish applications in the form of folders, war packages, and jar packages. Of course, you can also place the application anywhere on the disk and map it in the configuration file.

It comes with the following 5 items by default:

7. work directory

Used to store compiled files when tomcat is running (clear all contents in this directory and restart tomcat to clear the buffer)

Author: JD Technology Yang Jian

Source: JD Cloud Developer Community Please indicate the source when reprinting

Fined 200 yuan and more than 1 million yuan confiscated You Yuxi: The importance of high-quality Chinese documents Musk's hard-core migration server Solon for JDK 21, virtual threads are incredible! ! ! TCP congestion control saves the Internet Flutter for OpenHarmony is here The Linux kernel LTS period will be restored from 6 years to 2 years Go 1.22 will fix the for loop variable error Svelte built a "new wheel" - runes Google celebrates its 25th anniversary
{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/u/4090830/blog/10114536