Tomcat download address: http://apache.freeelamp.com/jakarta/tomcat-5//bin: Start the script file that starts and close Tomcat; / conf: Store Tomcat's various profiles, such as Server.xml / Server / lib: The various JAR files required to store the Tomcat server (JAR file can only be accessed by Tomcat server) / server / webapps: 2 Web applications that store Tomcat comes with: Admin Apps and Manager Applications. / Common / lib: The JAR folder where the Tomcat server and all web applications (Web and Tomcat servers can access this JAR) / share / lib: The JAR files that are accessible to the Web are available. (You can be accessed by Tomcat) / logs: Store Tomcat log file / WebApps: When publishing a web app, put the web application file in this directory / Work: tomcat Put by JSP The generated servlet is placed in this directory: In the web application, in the web-infroductory, you can also establish a lib sub-directory, and various JAR files can be stored in this subdirectory, which can only be accessed by the current web application. Among them, in the WEB-INF directory, the Tomcat class loader is loaded in the class of the class directory, then load the class in the lib directory. Classes is preferred because the class is the same name. Where JSP is running, find the order of the Class is: project folder (web-inf / lib) === "container folder (Tomcat / Common / lib) ==" JDK folder (JDK / JRE / LIB / EXT)
Tomcat's Class Loaded Priority List 1. The first is the JAR file under $ java_home / jre / lib / ext /. 2. Environment variables in the ClassPath in the JAR and Class files. 3. $ CATALINA_HOME / COMMON / CLASSES under the class file. 4. $ CATALINA_HOME / COMMONS / ENDORSED JAR file. 5. JAR file under Catalina_Home / Commons / I18N. 6. $ CATALINA_HOME / JAR file under Common / LIB. (JAR files such as JDBC driver can be placed here so you can avoid the case where Server.xml configuration data does not find JDBC Driver.) 7. $ CATALINA_HOME / Server / Classes under the class file. 8. $ CATALINA_HOME / Server / LIB / JAR file. 9. $ CATALINA_BASE / Shared / Classes under the class file. 10. $ Catalina_Base / Shared / LIB JAR file. 11. Class files under the specific webApp / Web-INF / CLASSES. 12. The JAR file under the respective specific webApp / Web-INF / LIB. Class search sequence is as follows ----------- / Web-inf / class of Your Web Application /Web-inf/lib/*.jar of Your Web Application $ CATALINA_HOME / COMMON / CLASS $ CATALINA_HOME /common/ndorsed/*.jar $ catalina_home / common / i18n / *. jar $ catalina_home / common / lib / *. Jar $ catalina_base / shared / class $ catalina_base / shared / lib / *. jar ------ ------- Therefore, the class files placed in different webapp will be loaded into different instances by ClassLoader. For example, it is assumed that the following two different contents of the Class are assumed. Put it in different webapp's class directory. package com.lizongbo; public class TestClass {private String NAME = "lizongbo";} package com.lizongbo; public class TestClass {private String NAME = "li_zongbo";} com.lizongbo.NAME at different webapp obtained results are different And does not affect each other. Note, Class Exceptions of the following headers: javax. * Org.xml.sax. * Org.w3c.dom. * Org.apache.xalac. * Org.apache.xalan. * Ps, pay attention. In each JAR The Class-Path key value pair in /meta-inf/mainfest.mf file will also provide JAR loading priority order.