AddressBook Final Project | XML and Web Services [CS277, NDNU] | December 2004
|
Specifications for the final project for NDNU's XML and Web services class were fairly loose: we were told to use the AddressBook XML schema [AddressBook.xsd] that we had defined during the class and create a means (using Java) to enter and edit contacts into the XML file [AddressBook.xml] comprising the addressbook. [AddressBook.xml has a stylesheet, AddressBook.xsl, associated with it, as you'll see when you click the links.] |
| |
|
I implemented the project as JavaServer Pages (JSPs), parsing and managing the file as a DOM structure. The starting menu (ContactManagerHome.jsp) parses the AddressBook.xml and generates a list of names (first name, last name) from the addressbook. Next to each name is a link to Edit or Delete [these pages won't work properly, because my website hosting service doesn't support JSPs or Servlets, thus I'm showing the screenshots in this write-up; click on any image to see an enlargement.] |
|
|
|
One of the most challenging aspects of this project has been trying to tease out the data from the XML file. You'll see the convoluted shenanigans I had to go through to get the information about a particular contact out of the XML file, in this findContact.jsp program listingthis took most of my time, and would provide the basis for jsps to add and edit contact information, but I've not completed those yet. The difficulty lies in the somewhat open-ended XML Schemathere's a lot of latitude in what elements can comprise a "Contact." | ||
|
For example, in some cases, a contact is married and has one or more children; in other cases not. Sometimes a person has a business and a work address; other times, not. I wanted the output to look decent, without empty values, and attaching labels to the data took an enormous amount of time. Another issue was getting a contact's children to display properly in the output form. Quite simply, I couldn't get the Children to display in the output form where I wanted them to, so you'll see that if a contact has children, the names and birthdays are at the top of the output, rather than at the bottom as I'd like them to be, as in the Add contact HTML page. |
| |
|
The entire project is contained in the addressbook.war file. To deploy on Tomcat, simply drop this .war file into the Tomcat \webapps directory, and the directory (addressbook) will be created, and the files comprising the application will be put in the appropriate structures. Then restart the Tomcat server (on current releases of Tomcat, the restart is not necessary). | ||
|
In addition to JSP, I also created an HTML front page (that closely resembles the JSP), but which calls a Servlet to provide the initial list of contacts from the addressbook. This is accessible on Tomcat at http://localhost/addressbook/contacts (assuming the .war file was deployed). As the AddressBook grows, it might be faster to access the simple HTML page and then search for a specific contact using the search feature [figure, right]. |
![]() | |
ConclusionOne of the most difficult aspects of this assignment was choosing an approach, both in terms of the user interface (Swing components or Web-based, for instance) and the underlying mechanisms to deal with the XML file (DOM? SAX? JAXB? JDOM? XOM? and so on). In working through the project, I (unfortunately) went down a lot of dead ends. I thought that JAXB might have been the way to go, but it seemed more complicated to me than just dealing with the DOM structures. |
| |
Updated ConclusionIn hindsight, Id like to mention an obvious point that concerned me all the while I was working on this project: This project would have been perfect for an RDBMS implementation, rather than XMLI never would have used XML for this type of a project. But it was a good exercise. Kelli Wiseth | ||



