How can I access a configuration and/or file (stored under WEB-INF) in a web application?

Charles Cuozzo

I place the and the appconfig.xml file in the WEB-INF/classes directory. (appconfig.xml is the other configuration file I spoke of.)

I get the locations as a URL object using the following code:

String logFile = getInitParameter("logger");  // or just logFile = ""
URL logurl = this.getClass().getResource("/" + logFile);
if(logurl != null)
  System.out.println(" not found!!");

I do pretty much the same thing to get my appconfig.xml file read in and parsed. I simply convert the URL into a string format and use that to parse the XML.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact