Here is an example that gets a URL to the file "myxmlfile.xml" that is contained in the war's WEB-INF/xml directory:
String xmlFile = getServletContext().getResource("/WEB-INF/xml/myxmlfile.xml").toString(); Depending on your XML library you might be able to open it directly passing this URL (JDOM has that capability) otherwise you can get the URL and do a little manipulation to get the absolute filename on your system.. This strategy works on every app server I have tested it on: JBoss, WebLogic, OAS, and WebSphere.. --- Stephen Ting <[EMAIL PROTECTED]> wrote: > Can anyone show me how access a xml file in .war > archive through a > relative path? > > I try using the following codes but in vain. > servlet.getServletContext().getRealPath(pathname) > which return null; > > servlet.getServletContext().getResourceAsStream(pathname) > also > > Thanks > > regards, > > Stephen > > __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user