On Wed, 3 Apr 2002, Wagoner, Mark wrote:
> Date: Wed, 3 Apr 2002 11:38:31 -0500
> From: "Wagoner, Mark" <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: 'Tomcat Users List' <[EMAIL PROTECTED]>
> Subject: RE: Working Directory
>
> I place my properties files in the WEB-INF directory and do the following to
> find them -
>
> String webInfFolder = getServletContext().getRealPath("/WEB-INF")
>
This only works if the app is run from an unpacked directory, which is not
guaranteed to be portable (not every server supports running this way).
The best way to read a properties file is to put it in the WEB-INF
subdirectory and use something like:
Properties props = new Properties();
InputStream stream =
getServletContext().getResourceAsStream("/WEB-INF/myprops.properties");
props.load(stream);
stream.close();
which is guaranteed to be portable to any server.
Craig
> -----Original Message-----
> From: Sanjay Bahal [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 03, 2002 11:34 AM
> To: tomcat
> Subject: Working Directory
>
>
> I am trying to read a properties file from my servlet.
> It always comes back saying file not found. I have
> tried placing the file in
> classes/web-inf/context-path. Ideally I would like to
> lace it in my classes directory- How do I achieve it.
> Thanks
> Sanjay
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Tax Center - online filing with TurboTax
> http://taxes.yahoo.com/
>
> --
> To unsubscribe: <mailto:[EMAIL PROTECTED]>
> For additional commands: <mailto:[EMAIL PROTECTED]>
> Troubles with the list: <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe: <mailto:[EMAIL PROTECTED]>
> For additional commands: <mailto:[EMAIL PROTECTED]>
> Troubles with the list: <mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>