Unable to locate the resource using classloader
hello all
i have cerated a simple web app with following structure.
-index.jsp
-WEB-INF
- lib
- cltest.jar
- web.xml
here
cltest.jar contains a class test.example.CLtest and my.prop file.
code of this class is
package test.example;
publicclass CLtest
{
static
{
System.out.println("Classloader -- " + CLtest.class.getClassLoader());
System.out.println("Resource -- "
+ CLtest.class.getClassLoader().getResourceAsStream(
"test/example/my.prop"));
}
}
also in my index.jsp i have
<%@ page import="test.example.CLtest" %>
<%
Class c= CLtest.class;
%>
Now
when i run the index.jsp in jboss server. i m not able to locate my.prop resource using
CLtest.class.getClassLoader().getResourceAsStream("/test/example/my.prop")
but
i amd able to locate it using
CLtest.class.getClassLoader().getResourceAsStream("test/example/my.prop")
So my question is whats the difference between
CLtest.class.getClassLoader().getResourceAsStream("/test/example/my.prop")
and
CLtest.class.getClassLoader().getResourceAsStream("test/example/my.prop")
thanks in advance

