File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Reading properties file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Reading properties file" Watch "Reading properties file" New topic

Reading properties file

Em Aiy
Ranch Hand

Joined: May 11, 2006
Posts: 226

I am setting up very basic web application. the application consists of 2 small applications.

1: web app
2: common app

The db related things are being done in common-app (connection, queries, etc - direct JDBC). and this common app is being added to the web app through JAR integration (using eclipse 3.3 include project). I want to keep my database connection properties in .properties file in the common app and read it when the first time servlet is called. But i am unable to do it. it gives me error that file not found. How should i setup?

I apologise if this is wrong section for this question.

The difference between <b>failure</b> and <b>success</b> is often being <b>right</b> and being <b>exactly right</b>.
Ankit Garg

Joined: Aug 03, 2008
Posts: 9465

did you put the properties file in the correct folder?? I think it should be in the WEB-INF\classes folder but your case seems different. You have an ejb module inside war module which I am not clear with what you are saying...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Em Aiy
Ranch Hand

Joined: May 11, 2006
Posts: 226
might be my explanation were not clear. let me try again

I have one project say tracker-web. which is simple SERVLET based web application. framework involved in it.

There is another project say tracker-common. Which has all the common classes (including db classes based on simple JDBC). Since this project is going to be include in 2-3 projects (tracker-web, tracker-command, tracker-reports etc). so i want to place the one JDBC PROPERTIES file in that common project. This common project will then in turn added to all above mentioend web projects as JAR file.

So i want to keep the properties file in the jar file and read it from there.

I don't prefer putting in web-inf folder. since i'll be having 3-4 projects and for each project i'll have to place 1 file in 3-4 places.
I agree. Here's the link:
subject: Reading properties file
It's not a secret anymore!