This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
Hi, What is the best way to determine the path for a properties file from within a servlet please? At the moment I have the path hard-coded inside a loadProps() method with the tomcat\bin as the 'root' like this: input=new FileInputStream( "../webapps/myWebapp/properties/props" ); but it would be nice if the webapp could work out the relative path of its own context so that it would still work even if the webapp is re-named. Many thanks, [ September 18, 2003: Message edited by: Peter Straw ]
If we want get the real path where the web application is located we could ask to the servlet context: servletContext.getRealPath( "/" ); This method will return a real path for a relative path. If we are in a web application context is /webapp_example, this method will return: c:/tomcat4/webapps/webapp_example/ Then if you want to acces to the WEB-INF directory you will write: servletContext.getRealPath( "/" ) + "WEB-INF/"; If you are in a servlet you could get the servlet context doing: request.getSession().getServletContext() I wait that i help you. See you