Tomcat directory structure
Note: The lib directory stores jar files, where:
Server/lib: jar files in the directory can only be accessed by the Tomcat server
Shared/lib: accessible to all web applications
Common/lib: accessible to Tomcat servers and all Web Applications
In addition, the jar stored in lib under the WEB-INF directory in each web application can be accessed by Tomcat and all web applications.
Create and publish Web Applications
Each component has a fixed storage directory in the Web application. the Web application configuration information is stored on the web. in XML, some components must be published on the web. add the corresponding configuration information in XML.
An application has WEB-INF/classes and WEB-INF/lib, both can store Java class files. during the running process, the Tomcat Class Loader Xi 'an loads classes under the classes directory and then the class under Lib. Therefore, if there are classes with the same name under the two directories, the class under the classes directory has priority.
Web. xml file
<? XML version = "1.0" encoding = "ISO-8859-1"?>
<! Doctype web-app public…>
<Web-app>
</Web-app>
The first line defines the XML version and character encoding.
Line 2 document types
Next, a <web-app> element is declared. All configuration elements about the web application will be added to this element.
Add the <context> element to server. xml
The <context> element is server. the most frequently used element in XML, which represents a single web application running on
Context attributes:
Path: Specifies the URL entry to access the Web application.
Docbase: Specifies the file path of the Web application. If it is a relative path, it is the value of the appbase attribute relative to the host.
Reloadable: if it is true, the Tomcat server will monitor changes to the class files under the WEB-INF/classes and WEB-INF/lib directories while running, if there is a class file update, the server automatically reloads the web application.
Tip: It is helpful for debugging to set reloadable to true in the development stage. however, this function will increase the load on the server. Therefore, we recommend that you set this attribute to false during the web application product release phase.