I want to pull in an xml file, however I seem to be having difficulty with the relative path. The file is on the root of src and is therefore replicated into the root of classes, however this fails indicating the file reference is invalid.
I am within a war (within an ear) however I am not in a servlet so I cannot take advantage of servletContext.
The following code fails indicating file not found. Any suggestions?
Ah yes, the difference between Class.getResourceAsStream() and ServletContext.getResourceAsStream().
Using the former requires the file be on the classpath; the latter as relative form the context root.
Joined: Feb 13, 2004
Yes thats true as well. Also "WEB-INF/classes/" is in the classpath so keeping "SearchCriteria.xml" file in there will make it easier.
Joined: Feb 27, 2009
Thank you for your recommendations. This works great. I had originally placed the file in \classes because there are some other related files at the root of \src and hence are copied to \classes. Your comments are right on and I will move my file to \WEB-INF.