Greetings, 

I've spent some time searching online and reading other threads here, such
as
http://www.nabble.com/where-to-put-config-file-in-a-webapp-td16448528.html#a16450373.

I have a question that wasn't quite answered there though.

I have a web app that needs to have property information set, such
as database IP, login, email server IP, login, etc.  Typically I would
put this in the WEB-INF/classes dir as a properties file.

My concern is this ends up being inside the war file distributed.  So
a user would have to expand the war to get at the properties file
and edit it.  If they configure tomcat to run the war without expanding
it, they now have to un jar it, edit the properties file, and jar it up
again.  I really don't want a consumer messing with the war at all,
or even going into the expanded dir.

I thought of just putting the properties file in the webapps dir, beside
the war itself and reading it with ClassLoader.getResourceAsStream();

1.  I don't see anybody else do this, so that suggests this is not the
best place to put the properties file.
2.  I was having some issues reading the properties file outside the war
file.

So my questions are:
1. Where is the best place to put the properties file
if I want it located outside the war itself?  

2. I can read it using ClassLoader.getResourceAsStream() or maybe
ClassLoader.getSystemClassLoader()?

I realize a consequence to this is if they run more than once instance 
of the app on different urls, they would both read the same config file.  
That's a corner case I don't think we'll ever run into, although if we did,
I could probably just have it read the app's configured uri as part of the
properties file (uri1.properties, uri2.properties, etc).

My ultimate goal is to give these instructions to a network admin:

1.  Download and install Tomcat
2.  Place war file in <TomcatDir>/webapps
3.  Put the app.properties file at __________ and set your database and
email server info.
4.  Start tomcat

Thanks very much!
-- 
View this message in context: 
http://www.nabble.com/Location-of-properties-file-for-web-app-in-Tomcat-tp21767095p21767095.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to