Reputation: 33902
I have a properties file in JAR
file.
In my web application, I want to access this properties file from the jsp
within web application.
I try doing it with the following code, but results in FileNotFoundException
Properties properties = new Properties();
properties.load(new FileInputStream("myfile.properties"));
How can i access the file from JAR
which is in my classpath
within scriptlets
in jsp?
Thanks in advance.
Upvotes: 0
Views: 718
Reputation: 8971
Yes you can using
InputStream in = this.getClass().getClassLoader().getResourceAsStream("//myfile.properties");
Make sure your jar file which has this property file is in classpath.
Upvotes: 0
Reputation: 42491
Not this way. You can try to get the Input Stream by using 'getResourceAsStream' functionality.
Read about this Here
Hope this helps
Upvotes: 2