The Code - Database Backed Web Servers: The “e-shoe Store” Implementation

The Code
Home Page
The “Home Page” is the main page of the E-Shoe Store. Upon accessing
http://tant14.cs.wisc.edu, the eShoeScript.pl script is called with no arguments and this page is generated. The Apache administrator must log onto tant14 and kick-start the Apache server in order to have access to the E-Shoe Store website. The E-Shoe Store’s home page is divided into three areas, a static area at the top (our banner) and two dynamic areas below the banner, one at the left and the other at the right. The left area allows searches to be performed and its field values are built dynamically by reading them in from the database. The right area displays the results of searches and allows selections to be made and added to the shopping cart. This area is also generated dynamically based on the search criteria (see figure below).
Cart Page
The Cart page performs various functions such as adding items to the cart, deleting items from it, or just viewing its content. It is called from the main page after a customer has performed a shoe search and wishes to add the desired shoe to his cart. The cart.pl script handles passing the desired data to the underlying Java program. This includes the selected shoe’s complete information when adding to the cart, no information when viewing the cart, and the selected shoe’s name when deleting from the cart. The Cart.java program writes the items being added or removed from the cart to a local text file named ‘cart’. These items will only be updated in the tables at checkout time, though the information contained therein needs to be kept accessible to the programs.
Check-Out Page
Our Check-Out page performs checking out the customer from the E-Shoe Store. Upon clicking the Proceed to checkout button on the Cart page, the CheckOut.java program is called via the check_out.pl script without any arguments. The program then reads in the content of the cart and displays it to the customer. Underneath these items, a customer information form is generated. This form prompts for first name, last name, address, etc., all of which will be passed to the upd_db.pl script. This script calls UpdateDB.java to update the customer table in the database.
The actual updating of tables happens when the Purchase button on the Check-Out Page is pressed. The program then updates the quantities of the purchased products in the size_qty table. Upon completion of the checkout process, the cart file is emptied and a thank you message displayed.
Thank you page
Creating a CS-564 Project
We certainly had to learn a lot in order to carry out the project successfully. At the onset of the project, Java was the only tool with which we had experience. We were compelled to learn everything else. Since this project was undertaken with the hope that it will serve as an assignment in CS-564, we believe that many of the obstacles that we had to go through should be spared from the students. Here are what we propose as potential projects.
Since CS-564 is a database course, we believe that only those things that relate to databases in this project should be assigned to the students. These elements include:
Using the JDBC API within Java programs to access the back-end database
Using the mmsql driver for Java (or any other driver)
Writing SQL queries and passing them to the back-end database
Building the inv, customer, and size_qty tables in MySQL following relational algebra rules such as normal forms and key constraints
We do not recommend adding dynamic HTML generation to the assignment. This may turn out to be too time consuming and does not focus on databases. Finally, we suggest with reservation that the students perhaps learn how to use the CGI interface to pass data between the HTTP server and the back-end database. This could be easily achieved via Perl scripts.
Conclusion
We have learned quite a few points throughout the course of this project. We highlight these points here as a conclusion to spare other implementors the agony of going through them.
First, one must observe that Apache is not easy to install and configure properly and that this task should definitely not be assigned to the students. MySQL for NT was straightforward to install and easy to use once installed. It accepts standard SQL statements and we believe that the students should have no problem using it or learning how to use it. In fact, knowledge of SQL is not essential to the project, as most of the project’s queries dealt with retrieving data or updating tables. This represents only a small portion of the SQL query language.
We also used Perl scripts to handle passing data (more specifically parameters) between the Apache server and our Java programs. Here again we believe that very little knowledge of scripting is required to achieve this. Other CGI scripting languages (Tcl, JavaScript, and so on) can also be used with the same results.
Third, we had to make extensive use of HTML in building our dynamic web pages. This should certainly not be part of a student project, especially if no prior HTML knowledge is given. Doing it otherwise may prove to be overly time consuming.
We did manage to successfully install the server on an isolated NT machine, to which we had administrative access. This will cause problems for the students. CSL does not grant undergraduate students administrative access to any machines. In addition, it does not allow installing and running web servers from university computers for obvious security reasons. We ourselves only learned of this fact two weeks before completing the project. The problem could be solved by requesting CSL to install Apache and MySQL onto a dedicated machine or perhaps on AFS, and allowing the students to access the machine or the AFS location. Since the CSL already maintains the department’s own Apache server, it is hoped that configuring the eventual CS-564 server should be a lot easier for them.
Finally, we suggest perhaps moving away from this more traditional CGI interfacing to more modern approaches such as Java Servlets. Companies in industry are strongly moving towards this direction, using Servlets, Active Server Pages, or CORBA Brokers. These new architectures enhance performance by avoiding the spawn of a process for every CGI request. In contrast, only one process is spawned and multithreading is used within this process to perform multiplexing. In addition, programming in these paradigms is made a lot easier and could lead to writing fewer program modules.
References
Apache
http://httpd.apache.org/
CGI & Perl
http://hoohoo.ncsa.uiuc.edu/cgi/overview.html
http://www.htmlgoodies.com/primers/perl/
http://www.cc.ukans.edu/~acs/docs/other/forms-intro.shtml
HTML & JavaScript
http://www.htmlgoodies.com/primers/basics.html
http://www.htmlgoodies.com/primers/jsp/
http://www.htmlprimer.com/
http://www.webcom.com/html/tutor/forms/
http://www.2kweb.net/html-tutorial/
JDBC
http://java.sun.com/j2se/1.3/docs/guide/jdbc/index.html
MySQL
http://www.mysql.com/documentation/index.html