Hi all, I have a class "xml_to_java". It is supposed to print out all the elements of "java_exam.xml". It is invoked from a servlet "trans_xml_java". I have the xml file in "/WEB-INF/" and both classes are in "WEB-INF/classes" Somehow I get the above io error. The only place where the class finds the xml file is when the xml file is in "jakarta-tomcat/bin". I also copied the file in the root of my application, but it doesn't work. Any idea what I'm doing wrong? Regards, Francois.
With tomcat the default file location is /bin directory, its not a good idea to place the work files under the bin directory - because not all servlet containers can read it. My idea could be create a directory xmlfiles under web-inf and refer its location in web.xml file
<context-param> <param-name>xmlfileloc</param-name> <param-value>/web-inf/xmlfiles</param-value> <description>Default xml file location</description> </context-param>
Now in ur servlet try to get this parameters with the following code String xmlfileloc = getServletContext().getInitParameter("xmlfileloc");
Hi Balaji, Sorry about the late reply. What you mention still doesn't work. Even if I hardcode the path, tomcat can't find the file. Here's my setup in tomcat: <webapps>/<my_appl>/source code <webapps>/<my_appl>/<WEB-INF>/<classes>/*.class <webapps>/<my_appl>/<xmlfiles>a_xmlfile.xml I use Tomcat 4.1.18 and I have the following code in xml_to_java.class xml_nm = "\my_appl\xmlfiles\java_exam.xml"; XMLReader xr = XMLReaderFactory.createXMLReader( "org.apache.xerces.parsers.SAXParser" ); xr.setContentHandler( this ); xr.parse( new InputSource( new FileReader( xml_nm )) ); This won't work. The only xml file it reads is the one in the bin subdirectory. What else am I missing in Tomcat setup?