Servlet Containers and Class Path

What is the class path for the Servlet container set?

According to my understanding, three components are involved. JAR files in the lib directory of the Servlet container, and then classes in the WEB-INF/classes and JAR files in the WEB-INF/lib . Classes in the lib directory of the Servlet container are added to the system class path, and the dynamic class path includes JAR files in the lib directory and classes in the classes directory.

What is the set of dynamic class classes? Does the dynamic path point to all directories under WEB-INF or include all the individual classes and JAR files in WEB-INF/lib and WEB-INF/classes or just point to two directories WEB-INF/classes and WEB-INF/lib ? Let's say I have a directory called foo in WEB-INF containing bar.properties . Now bar.properties also in the class path?

+10
java java-ee servlets
Nov 20 '08 at 13:25
source share
2 answers

The "dynamic" classpath will display WEB-INF/classes , each JAR file under WEB-INF/lib as a separate entry. Other folders under WEB-INF not included.

In your example, bar.properties will not be in the classpath. Move it to WEB-INF/classes or put it in a JAR file under WEB-INF/lib .

Which in the rest of the classpath depends on your Servlet container. It is implementation specific, but most containers have two other places to place classes. One of them is the directory that is displayed to the container, but not the application, and the other to the container and all applications. Since the second ClassLoader is visible to all applications, the static members of these classes can be used to exchange information between applications.

+7
Nov 20 '08 at 16:24
source share

In your example, bar.properties should be under the class directory, located on the class path.

+2
Nov 20 '08 at 13:31
source share



All Articles