Hi,

>With Tomcat 5.0.24 running as a service, where would the "current
>directory"
>be?  5.0.18 allowed you to specify --WorkingPath "%CATALINA_HOME%\bin"
in
>service.bat, but this setting is ignored now in 5.0.24.
>
>I need to open some config files from the current directory at startup.
>
>BTW how does the technique work to "grab a resource" from the
CLASSPATH?
>Maybe I only need to put the config files in the classpath in that
case.
>(or in the WEB-INF directory of the service?).

Using Class#getResource is a great portable way to read configuration
files.  Place the config files under WEB-INF/classes, and then say (from
any object) getClass().getResource("/myFile.prop") to get a URL to the
file (for libraries that will take a URL), or getResourceAsStream to get
an InputStream for reading.  Read the JavaDoc for Class#getResource
(actually ClassLoader#getResource as you'll see) for full details.

Using ServletContext#getResource is similar and also very good.  Files
don't have to be on the classpath, they can be anywhere under the
webapp's root directory.  For example, put them under WEB-INF/config and
call getServletContext().getResource("/WEB-INF/config/myFile.prop") to
get the URL, or getResourceAsStream for the stream.

Either of those approaches is many times better than the current working
directory approach, which is the portability equivalent of a fly on the
path of a sumo wrestler to his food.

Yoav Shapira




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to