logo
header art

Getting Started with Ajax

June 23, 2005

Part 2: Serving Useful Information as XML
In Part 1 of this article we focused on the client aspect of an Ajax example that retrieved note information from a static XML file. In this part, we will focus on the server side as we build a more sophisticated solution for serving information for a pageable data table.
Application Overview
As in the example in Part 1, this example uses the xmlOpen(...) Javascript function to request information from the server. We will skip the client side details since they have already been discussed. In order to properly serve the Ajax requests, our application will consist of a few Java classes:
  • TableServlet is located in the com.skillfusion.xmlhttprequest.servlets package and is responsible for processing the incoming Ajax request and responding with valid XML. This class will delegate data retrieval to the TableManager.
  • TableManager is located in the com.skillfusion.xmlhttprequest.util package and is responsible for supplying valid XML data for a single page of a table. It is a very simple table manager and does not support filtering or sorting. However, these features could easily be added in a production system. For simplicity, this class uses hard coded data instead of accessing an external data source. In a production system, this class would probably get the data from a database, web service, xml data set, etc.