views:

559

answers:

2

To what is the class path of a servlet container set to?

As per my understanding there are three components involved. The jars in the lib folder of the servlet container and then the classes in the WEB-INF/classes and jars in the WEB-INF/lib folder. The classes in lib folder of the servlet container are added to the system class path and the dynamic class path contains the jars in the lib folder and classes in the classes folder.

Where is the dynamic class path set to? Does the dynamic class path point to all the folders under WEB-INF or includes all the individual classes and jars in WEB-INF/lib and WEB-INF/classes or just points to the 2 folders WEB-INF/classes and WEB-INF/lib? Say I have a folder called foo in WEB-INF containing bar.properties. Now is bar.properties also in the class path?

+2  A: 

In your example bar.properties would need to be under the classes directory to be in the classpath.

rich
+3  A: 

The "dynamic" class path will list WEB-INF/classes, each JAR under WEB-INF/lib as a separate entry. Other folders under WEB-INF are not included.

In your example, bar.properties will not be on the class path. Move it to WEB-INF/classes, or put it inside a JAR under WEB-INF/lib.

What's in the rest of the class path depends on your servlet container. It is implementation specific, but most containers have a two other places to put classes. One is a directory that is visible to the container, but not the applications, and the other is visible to the container and all of the applications. Since the second classloader is visible to all of the applications, static members of those classes can be used to share information between applications.

erickson
If other folders under WEB-INF lib are included then should not the properties file be included in the class path?
Abhi
Sorry, that was an important typo, i meant "NOT included"!
erickson