Howdy,
Yeah, I usually prefer ServletContext#getResource or getResourceAsStream
over the Class loader approach (Justin's suggestion) as well.
Yoav Shapira
Millennium ChemInformatics
>-----Original Message-----
>From: news [mailto:news@(protected)
>Sent: Tuesday, October 14, 2003 2:14 AM
>To: tomcat-user@(protected)
>Subject: Re: Can I read file resources from a .WAR file at runtime ?
>
>Justin's suggestion works, but personally I prefer using:
> InputStream is =
>getServletContext().getResourceAsStream("/WEB-INF/myresource");
>
>"Steph Richardson" <steph@(protected)
>news:CCEJLCOJKFBHFPKFNNABEEHKDDAA.steph@(protected)...
>>
>> I have a web-app that uses several xml, xsd, and other configuration
>files
>at runtime ( including during the Application Init
>> event ). We keep these files under various directories under WEB-INF
so
>that we can get their paths at runtime relative to
>> ServletContext.getRealPath( "WEB-INF" ).
>>
>> When I am deploying this web-app as a war file, I can detect I am a
war
>file at runtime because ( getRealPath( "" ) == null ), but
>> is there a consistent way to read a file from this war file ?
>>
>> Thanks
>>
>> --------------------------------------------------------
>> Steph Richardson
>> Kvasar Technology LLC
>> HQ: suite 106, 822 Boylston st., Chestnut Hill, MA 02467
>> smtp : steph@(protected)
>> http : www.kvasar.com
>> --------------------------------------------------------
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
>For additional commands, e-mail: tomcat-user-help@(protected)
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: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)