Servlet containers and classpath

后端 未结 2 465
伪装坚强ぢ
伪装坚强ぢ 2021-01-04 09:50

To what is the class path of a Servlet container set?

As per my understanding there are three components involved. The JAR files in the lib directory o

相关标签:
2条回答
  • 2021-01-04 10:07

    The "dynamic" classpath will list WEB-INF/classes and each JAR file 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 classpath. Move it to WEB-INF/classes, or put it inside a JAR file under WEB-INF/lib.

    What's in the rest of the classpath depends on your servlet container. It is implementation-specific, but most containers have 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.

    0 讨论(0)
  • 2021-01-04 10:18

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

    0 讨论(0)
提交回复
热议问题