Dragos Haiduc

Greenhorn
+ Follow
since Mar 05, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Dragos Haiduc

try using this as your url pattern:
<url-pattern>/Example</url-pattern>
20 years ago

Originally posted by Zak Nixon:
How do I add files to my classpath for the webserver to pick it up?


Step 1. Place your properties file "fileName.properties" under the WEB-INF/classes folder of your web application.
Step 2. From a Java class of the same web application( this class must also be somewhere in WEB-INF/classes ) try the call:
InputStream is = getClass().getResourceAsStream("/fileName.properties");
This MUST work.
PS: Please provide more detailed info about your servlet-engine, if possible.
[ March 09, 2004: Message edited by: Dragos Haiduc ]
[ March 09, 2004: Message edited by: Dragos Haiduc ]
20 years ago
I think you should also add a reference to your EJB in your web.xml descriptor with the help of the <ejb-ref></ejb-ref>tag.
20 years ago
Of course i am treating properly that IOException.
However, i made the post simplified like earlier because i thought getting the InputStream for that property file was more important here.
20 years ago
Here is what i do(i think the web application classloader(s) can't "see" past WEB-INF/classes). My properties file is placed in WEB-INF/classes.
My class loading this file is of course in a package under WEB-INF/classes.
File is named "jdbc.properties".
Here is the call:
Properties props = new Properties();
InputStream is = this.getClass().getResourceAsStream("/jdbc.properties");
try {
props.load(is);
is.close();
} catch (IOException ioe) {}
This always works, file can be modified when the servlet engine is running, a simple reload of my application context being enough for it to be able to use the modified properties file.
[ March 05, 2004: Message edited by: Dragos Haiduc ]
20 years ago