Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Read a .properties file in a servlet loaded on Tomcat

843842Sep 9 2009 — edited Sep 10 2009
Hi,

I am facing some problems when I want to read a properties file. Basically, I have a servlet (ExtractorServlet) which accesses a java class (MessageExtractor.java). This java class reads a properties file (MessageExtractor.properties). For now, I am using this line of code in MessageExtractor.java to load the file:

Properties properties = new Properties();
properties.load(ClassLoader.getSystemResourceAsStream("MessageExtractor.properties"));

when running it on eclipse, it works... but when i load the WAR file to a Tomcat Server, it cant access this file. I tried placing the MessageExtractor.properties file in the /WEB-INF and /WEB-INF/classes directory of the WAR file but still useless...

Would certainly appreciate some help.. thanks in advance!! :)

Cheers,
Khew
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 8 2009
Added on Sep 9 2009
4 comments
1,075 views