File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Problem Reading Property File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem Reading Property File" Watch "Problem Reading Property File" New topic

Problem Reading Property File

R.A.Partha sarathy

Joined: Sep 30, 2003
Posts: 9
hi all
i have a servlet which will connect to Database and fetches some DATA.i have a which will have the connection string ,query,and.....the problem is the servlet is not able to read the properties file.actually where we can place the properties present i have this servlet in project root directory.
when i put this properties file in WEB-INF\Classes its working. but that is not a right way to do it.
Help ME,
thanks and regards
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 642
can u pl tell y is it wrong way to put properties file under web-inf/clasess ?

All desirable things in life are either illegal, banned, expensive or married to someone else !!!
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

u = you
pl = please
y = why
clasess = classes
Please reduce the use of contractions. When you combine accidental spelling and grammar mistakes with people from around the world who may not have English as their primary language, contractions just make posts harder to understand and should be avoided.
The point is well made though: if it works, why is WEB-INF/classes the wrong place for the properties file?
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 642
Thank You (thanx ) David,
I will keep This In mind.
Amit KumarS
Ranch Hand

Joined: Oct 10, 2003
Posts: 100
Hi parth..
you can do this in following manner

so in this case the name of the properties file should be and in my case it is in the conf directory of the root of your application.
and it is not wrong to put the properties file in classes directory.. only thing is that putting it in seperate directory makes it more viewable and seperates the code files from different files as we keep our HTML file, JSP files, and image files in different folder though it is not wrong to keep them together.
i hope i have answered correctly. if doubt please revert back

****************************<br />In 24 hrs Earth rotates once on its Axis.
I agree. Here's the link:
subject: Problem Reading Property File
It's not a secret anymore!