Re: How to specify the location of a properties file.

2002-10-09 Thread Shaun Campbell
Justin I have written my properties loading like this and I found once that it loaded from the classes directory. I guess the question I have is why it defaults to the classes directory and how could I set to something like a conf directory below my main webapp root directory. The other thing

Re: How to specify the location of a properties file.

2002-10-09 Thread Justin Ruthenbeck
Hey Shaun -- If the resource name given to getResourceAsStream() isn't found in the web application locations (WEB-INF/classes, WEB-INF/lib, Tomcat-specific locations), then the system class loader searches for the given resource in your classpath one entry at a time. If the properties file

Re: How to specify the location of a properties file.

2002-10-08 Thread Mehdi . Nejad
I use the getResourceAsStram() method also, but i find that my IDE, tends to remove the properties file from my classpath, as soon as I do a build, which is not nice. In the particular case i have now, I don't want to specify the parameters in my web.xml, because the utility that requires a

Re: How to specify the location of a properties file.

2002-10-08 Thread Andreas Probst
Hi Mehdi, I have my properties file in /WEB-INF. Eclipse doesn't delete it there. I access it with InputStream propsIn = servletContext.getResourceAsStream(/WEB- INF/dms.properties); props.load(propsIn); As far as I know this also works when the web-app ist deployed as a war without

Re: How to specify the location of a properties file.

2002-10-08 Thread Mehdi . Nejad
Hi, There was no ServletContext.getResourceAsStream () ... maybe this is because the whole project is a bunch of utilities for my web-app, and is not a webapp itself ? The class that needs the properties file, is not part of the webapp. So anyway, i tried the closest available method.. (or so i

Re: How to specify the location of a properties file.

2002-10-08 Thread Andreas Probst
Hi Mehdi, you could get the resource stream from within a servlet's init() method (where you have a ServletContext) and pass it to the other object that needs it. I do it pretty similar. But instead of passing the stream I pass the servletContext. Andreas On 8 Oct 2002 at 15:40, [EMAIL

RE: How to specify the location of a properties file.

2002-10-08 Thread Donie Kelly
Here is the simple solution ServletContext sc; String RootPath=null; sc = getServletContext(); RootPath = sc.getRealPath(/); Donie -Original Message- From: Andreas Probst [mailto:[EMAIL PROTECTED]] Sent: 08 October 2002 16:31 To: Tomcat

RE: How to specify the location of a properties file.

2002-10-08 Thread Andreas Probst
Yes Donie, but this won't work if the webapp is deployed as a war without expansion. Andreas On 8 Oct 2002 at 17:06, Donie Kelly wrote: Here is the simple solution ServletContext sc; String RootPath=null; sc = getServletContext(); RootPath =

Re: How to specify the location of a properties file.

2002-10-08 Thread micael
Here is a teaching class that shows all you need to know about regular access to properties files, Mehdi: /* tccjava.toolbox.io.properties.PropertiesManager December 15, 2001 * * Copyright 2001 Swords and Ploughshares, Ltd. All Rights Reserved. * * This software is the proprietary

Re: How to specify the location of a properties file.

2002-10-07 Thread Justin Ruthenbeck
Shaun -- Consider dynamically loading the properties file from your classpath using a class loader. This way, you can put the files anywhere you please and just include that directory in your classpath (or put them someplace already in your classpath). If you need more specifics, let me

Re: How to specify the location of a properties file.

2002-10-07 Thread Niaz Habib
Justin, I am facing the same problem. Your approach seems to be an elegent one. Would you mind eleborating on the idea a little bit more. Some code snippet would definitely be helpful. I thank you in advance. niaz. - Original Message - From: Justin Ruthenbeck [EMAIL PROTECTED] To:

Re: How to specify the location of a properties file.

2002-10-07 Thread Justin Ruthenbeck
Niaz ... The idea is to load the properties file like you would any other java resource at runtime ... this is (almost) always better, IMHO, than using something J2EE-specific like initialization parameters to a servlet. The relevant code would look something like this: InputStream inStream

Re: How to specify the location of a properties file.

2002-10-07 Thread Glenn Nielsen
Put the properties file in the /WEB-INF/classes directory and use ResourceBundle.getBundle(foo); The name of the properties file without .properties. Regards, Glenn Niaz Habib wrote: Justin, I am facing the same problem. Your approach seems to be an elegent one. Would you mind