Chapter 15 600 The Server-Side Classes We start with the main driver for the server side code; VacationServlet. The servlet does very little other than setting handling the HTTP GET transaction and calling the methods of an embedded up an XMLRPC call by registering an instance of a DealsFinder object. com.wrox.pjxml.DealsFinder is essentially a relational-to-XML mapping class. It has one method, locateDealsXML(), that is called by the servlet. Given a trip number, it will perform a query on the sell-off database using JDBC to obtain all trips with greater trip numbers (which therefore arrived later) than those in the previous update of the client. This data is then placed into a DOM using a DOMBuild instance. The DOM is written out to XML using a DOMWriter instance. The output is converted into a String and returned as the response to the servlet, which in turn send the XML as a response to the client. There are four more classes concerned with the data source and the two DOM classes mentioned above. We will start with the JDBC classes: com.wrox.pjxml.sqlBean is a JDBC helper class. It manages the connection to and disconnection from the JDBC source. In a production environment, we could modify this class to make use of connection pooling support, etc., supplied by the container. The other JDBC helper class is com.wrox.pjxml.queryBean. It has a method that supports query by trip number. It inherits from sqlBean. com.wrox.pjxml.DOMBuild uses the DOM support in the Apache Xerces library. It takes the resultset returned from a JDBC query and builds an XML DOM tree with it. The final class, com.wrox.pjxml.DOMWriter, is a simple modification of a sample class supplied with Apache Xerces. It writes out a DOM tree as XML. We use this to create the XML string of new trips that is then shipped back to the client. Filtering Disconnected XML Dataset: VacationApplet The VacationApplet class manages the user interface seen by the travel agency customers. The screenshot below shows how this user interface should look. It makes use of standard Java AWT widgets, enabling it to run on browsers that support the earliest 1.x JDKs.