Question about cutom tag jars on Tomcat
I have written a custom tag for data connection in Java and wrote a TLD to use it. My problem is a I have three applications that all use it, so I put the jar file in my CATALINA_HOME/common/lib and the tld finds the jar but the jar has a properties file it uses to get the DB name and user names. The jar can not find the properties file, I tried putting it in the common/lib/, I put it in the common/ and I also tried in the APP_DIR/WEB-INF/ and it still can not find them. Is there a place I can put the properties file that tomcat will have it available for the jar file.
Thanks in advance
# 1
Put the properties file inside the jar file. Then you can load it from your code using the classloader. Lets say you put the properties file in a subdirectory "props" inside the jar, you can then load it using this code:
InputStream is = this.getClass().getClassLoader().getResourceAsStream("props/db.properties");
Properties props = new Properties();
props.load(is);
is.close();
Assuming you name your file "db.properties" of course.
# 2
Yeah, I thought about that, the only thing that was stopping me from doing it that way, is the ability to change on the fly without reloading the context, so if I/someone needs to change DB password they don't have to change the jar. But I guess I am just going to surrender to the flow. Thanks for your reply!