Major web servers such as Tomcat implement more than one custom ClassLoader for the following basic functions:
(1). The Java class libraries used by two Web applications deployed on the same server can be isolated from one another.
(2). The Java class libraries that are used by two Web applications deployed on the same server can be shared with one another.
(3). Many Web servers themselves are implemented in the Java language, so the class library used by the server should be independent of the application's class library.
(4). The Web server that supports the JSP application needs to support the HotSwap function, because the JSP file is ultimately run by a servlet compiled as Java, and when the JSP file is modified, it is not necessary to restart the server for a hot deployment.
The TOMCAT5 and TOMCAT6 class loading architectures are distinguished by the use of Tomcat as the representative of the JDK-recommended parental delegation model implementation of the Orthodox class loader:
TOMCAT5:
The directories in TOMCAT5 that can hold Java class libraries and Web applications are as follows:
(1)./common Directory: The class library can be used by both the Tomcat server itself and all Web applications.
(2)./server Directory: The class library can be used by the Tomcat server itself and is not visible to the application.
(3)./shared Directory: The class library can be used by all applications and is not visible to the Tomcat server itself.
(4)./webapp/web-inf Directory: Class libraries can only be used by applications and are not visible to other applications and Tomcat servers.
The class loading architecture for TOMCAT5 is as follows:
TOMCAT6:
Tomcat defaults to merging the/common,/server, and/shared three directories into a single/lib directory, so TOMCAT6 can store the Java class Library and the Web App directory as follows:
(1)./lib Directory: The class library can be used by both the Tomcat server itself and all Web applications.
(2)./webapp/web-inf directory: Class libraries can only be used by applications and are not visible to other applications and Tomcat servers.
The default class loading architecture for TOMCAT6 is as follows:
In Tomcat6, you can install the directory by specifying <tomcat >/conf/ The Server.loader and Share.loader in the Catalina.properties properties file establish and Tomcat5 similar serverclassloader and Sharedclassloader.
(go) Deep understanding Java Virtual Machine Learning Note 8--tomcat class loader architecture