Hi Josh,

I tried your second approach:
requestGlobals.getHTTPServletRequest().getSession().getServletContext().getRealPath("app")

it returns : /usr/local/apache-tomcat-5.5.23/webapps/my_app_context/app

but I checked the running program, the file is here
/usr/local/apache-tomcat-5.5.23/webapps/ROOT/WEB-INF/info.xml

if I set the application context to "/", i got 

/usr/local/apache-tomcat-5.5.23/webapps/app  and the file still in the same
place, seems difficult to link the real path to the actual WEB-INF, any
idea? Thanks,

A.C.





Josh Canfield-2 wrote:
> 
> Since, I assume, you are deploying your web application into a servlet
> container you are not going to be able to use a relative path to get at
> the
> file. Tapestry isn't doing the loading of the file so using any Tapestry
> related path constructs is not going to work.
> 
> Your best bet is putting your file in the classpath and using the
> classloader's getResource or getResourceAsStream methods to load it.
> 
> You could also try to use the ServletContext to find where it's physically
> loaded on the disk
> String path = request.getSession().getServletContext().getRealPath("app");
> // app is the name of your servlet/filter
> But there are some significant caveats:
> If you are using a secure app server then you may or may not be allowed to
> read the file from this location.
> If you have deployed into a WAR file then this also may not help (if the
> WAR
> isn't exploded).
> 
> So, put it in the classpath and use the classloader to find it.
> 
> Josh
> 
> On 9/1/07, Angelo Chen <[EMAIL PROTECTED]> wrote:
>>
>>
>> Hi,
>> I have this info.xml file that I need to open, first I put it under
>> WEB-INF
>> and use : fr = new FileReader("info.xml"); got FileNotFoundException, I
>> put
>> it under images directory as the template was able to get the pictures
>> there, then I use FileReader("images/info.xml"), same exception. where is
>> the better place to put xml files and what's the correct path to access
>> them? thanks.
>>
>> A.C.
>> --
>> View this message in context:
>> http://www.nabble.com/T5%3A-xml-file-location-tf4364651.html#a12440650
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> 
> -- 
> --
> TheDailyTube.com. Sign up and get the best new videos on the internet
> delivered fresh to your inbox.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/T5%3A-xml-file-location-tf4364651.html#a12445945
Sent from the Tapestry - User mailing list archive at Nabble.com.


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

Reply via email to