%@page import="java.util.*, org.w3c.dom.Node, org.w3c.dom.Element, org.w3c.dom.Document, org.w3c.dom.NodeList, javax.xml.parsers.DocumentBuilder, javax.xml.parsers.DocumentBuilderFactory" %> <%! DocumentBuilder addressBookParser; Document addressBook; Element contact; int count; Vector contactID = new Vector(); %> <%@ include file="contactManagementSystemHeader.html" %> <% DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating( false ); DocumentBuilder addressBookParser = dbf.newDocumentBuilder(); Document addressBook = addressBookParser.parse("http://localhost:80/addressbook/AddressBook.xml"); addressBook.getDocumentElement().normalize(); NodeList contactsAll = addressBook.getElementsByTagName("Contact"); NodeList namesAll = addressBook.getElementsByTagName("Name"); count=contactsAll.getLength(); %>
| This application uses JavaServer Pages (JSPs), Servlets, and Java classes to parse an XML file (AddressBook.xml) and display a listing of all names. You can search for a specific name to display the entire infoset about that contact, you can add new contacts, delete existing contacts, and update the infoset about a specific contact, all from this starting page. | ||||
| Add a new contact | Search for a specific contact | |||
| AddressBook Listing | ||||
| Last name | First name | Manage this contact: | ||
| <%= lastNameText %> | <%=firstNameText%> | Edit | Delete | |