Use ServletContext.getResourse (returns a URL) or ServletContext.getResourceAsStream (returns an InputStream). These methods will work for both expanded (directory) and non (war) deployments.
Tim -----Original Message----- From: Martin Grogan [mailto:[EMAIL PROTECTED] Sent: Friday, May 19, 2006 3:31 AM To: Tomcat Users List Subject: Re: deploying myapp.war as "/" - confused Hello, I'm not sure if I understand your question, but for finding files that are relative to the current context, I use ServletConfig config config.getServletContext().getRealPath(your_file_here) Maybe that's not the correct way to be doing things??? But it works for me. Martin Nikita Tovstoles wrote: > Thanks - that was simpler than I thought. Follow up bonus question: > what's the new "current directory" of ServletContext? Here's what I mean: > > I had the following code in servlet context listener inside myapp.war > getting properties from a .properties file *outside* the .war: > > ServletContext.getResourceAsStream("../myapp.properties"); > > This used to be my directory structure: > > $catalina.base/ > webapps/myapp.war > webapps/myapp > webapps/myapp.properties > > Now that I'm deploying ROOT.war instead of myapp.war, the above line > can't find myapp.properties. Here's the current dir structure: > > $catalina.base/ > webapps/ROOT.war > webapps/ROOT > webapps/myapp.properties > > So, when I was deploying myapp.war, ServletContext's "current dir" was > webapps/myapp. What's the new "current directory" of ServletContext > for ROOT application? > > thanks > -nikita > > Mark Thomas wrote: > >> Nikita Tovstoles wrote: >> >>> Hi, >>> >>> I have myapp.war that I'd like to deploy by copying myapp.war to >>> catalina.base/webapps; but I would like to bind the app to context "/". >> >> >> Rename it to ROOT.war >> >> Mark >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- ------------ Martin Grogan Keizen Software [EMAIL PROTECTED] www.keizensoftware.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]