|
the best place to put things like data (xml files) is inside the WEB-INF folder, if it is desireable to have the XML file live within the web application. and then the method ServletContext#getResourceAsStream() is useful for figuring out the deployment-dependent path relative to the webapplication, and fetching you an open InputStream, which can then be used with the XML parsers.
If the XML file must exist externally to the web application, a good idea is to define an context parameter in the web.xml, or maybe use a JNDI environmnt variable name, which can be overridden with the container-specific deployment descriptor. for example, tomcat's context.xml could provider the resource binding for the physical external to the web application path, and the code inside your webapp would fetch a handle to the jndi variable name in a deployment-independent manner.
|