This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes how to access properties file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to access properties file" Watch "how to access properties file" New topic
Author

how to access properties file

Gerome Kawa
Ranch Hand

Joined: Dec 05, 2002
Posts: 61
Hi

I need to use a properties file to replace variables in a Java program and a servlet.

Eg. of Java program:
****************************************************

****************************************************
The servlet:

********************************************************************
I want to put the stuff between @xyz@ in the above programs in a properties file and access them - how do i do it?

I want to stuff @xyz@ in the servlet to come from a init-param of the servlet defined in web.xml .

Question:
Where should I put the properties file ?
How do i access it(the variavles in the properties file) from java program?
Do i need to put the properties file in the classpath?

Thanks
Kawa

[EDIT code tags added by Dave]
[ February 10, 2005: Message edited by: David O'Meara ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

http://wiki.apache.org/jakarta-tomcat/HowTo

Third item on the page. It should answer all of your questions.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Here's a pointer for you: SimpleDateFormat isn't thread safe! It should be but is not.

Don't make it a static final, create a new one each time you need it, or as a method variable (NOT an instance variable, this is a servlet we're talking about).

Just be glad you're not learning this the hard way!
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

and after 56 posts it's time for you to experiment with UBB's code tags
 
wood burning stoves
 
subject: how to access properties file
 
Similar Threads
httpServlet returns anonymous
A Mirroring Algorithm
getRemoteUser is always anonymous
file uploading through servlet
Thread not waking up after sleep