%@page import="kap.web.UserBean, kap.web.Info, java.io.File, java.io.IOException, javax.xml.parsers.DocumentBuilder, javax.xml.parsers.DocumentBuilderFactory, javax.xml.parsers.FactoryConfigurationError, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, org.xml.sax.SAXParseException, org.w3c.dom.Document, org.w3c.dom.Element, org.w3c.dom.Node, org.w3c.dom.NodeList, org.w3c.dom.NamedNodeMap, org.w3c.dom.DOMException" %> <%@ include file="XML_Reader_Methods.jsp" %> <% // Let's read in a jsp file and display it as nested lists // is there a file specified? String xmlFileParameter = request.getParameter ( "xml-file" ); String xmlFile = xmlFileParameter; String xmlDefault = "logon/users.xml"; if ( xmlFile == null || xmlFile.equals ( "" ) ) { xmlFile = xmlDefault; xmlFileParameter = ""; %> No XML file specified, using default of "<%= xmlDefault %>" <% } // end if no xml file specified else { if ( ! Info.FileExists ( Info.filePath ( this, request, xmlFile ) ) ) { %> File "<%= xmlFile %>" does not exist, using default of "<%= xmlDefault %>" <% xmlFile = xmlDefault; } // end if file does not exist } // end else a file is specified, make sure it exists // document representing the user xml data file Document document = null; DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); document = docBuilder.parse ( new File ( Info.filePath ( this, request, xmlFile ) ) ); } // end try reading in user xml file catch ( SAXParseException spe ) { %> SAXParseException: <%= spe.getMessage() %> <% } // end catch SAX parse exception %>
<%= printNode ( document, 0 ) %>