Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2006

Tip: Looking for answers? Try searching our database.

Configuration params for a webapp - best practice?

Thread view: 
Steve - 30 Aug 2006 22:04 GMT
Hi,

I have a web app running in Tomcat and it can be configured with various
parameters.

In particular, one of the parameters is a file path that defines where
various work files, uploaded files and logs are written to.

I have created a config file in this folder for other parameters but
ultimately something needs to define this path.

My first attempt had the path hard-coded but now I realise that's probably
not right, since I have to install the web app on Windows and Unix machines.

So then I checked the 'os.name' system property but that only gave me a Unix
version and a Windows version of the path - still ultimately hard-coded.

Where is the best place to configure this path so it's not hard coded in the
web app and is easy to configure when the app is deployed?

Thanks very much.

Signature

Regards,
Steve

"...which means he created the heaven and the earth... in the DARK! How good
is that?"

Arne Vajhøj - 31 Aug 2006 02:27 GMT
> I have a web app running in Tomcat and it can be configured with various
> parameters.
[quoted text clipped - 13 lines]
> Where is the best place to configure this path so it's not hard coded in the
> web app and is easy to configure when the app is deployed?

readonly => put it in the war

single app Tomcat => JVM arg -Dmy.config=...

Java 1.5 => set a variable and get it in web app with System getenv

fallback => OS neutral absolute path like "/mycfg"

Arne
Chris Smith - 31 Aug 2006 05:03 GMT
> Where is the best place to configure this path so it's not hard coded in the
> web app and is easy to configure when the app is deployed?

The right way to do this is to put the information in a context
initialization parameter.  From any servlet, you can access this
information from the ServletContext object.  You can put a default value
into web.xml, and then the servlet container will provide a mechanism to
configure the parameter for a particular deployment (for example, in
Tomcat, you'd use server.xml in the conf/ directory).

Signature

Chris Smith

Steve - 31 Aug 2006 19:36 GMT
On 31/8/06 05:03, in article MPG.1f600d5ff65871c29896e6@news.altopia.net,

>> Where is the best place to configure this path so it's not hard coded in the
>> web app and is easy to configure when the app is deployed?
[quoted text clipped - 5 lines]
> configure the parameter for a particular deployment (for example, in
> Tomcat, you'd use server.xml in the conf/ directory).

Thanks Chris.

Signature

Regards,
Steve

"...which means he created the heaven and the earth... in the DARK! How good
is that?"



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.