Providing Customer Functionality

Phase 2


Overview

Now that the FabFlixs database is built, we add functions to allow customers to browse through the movies available for purchase, search for movies by specific criteria, add movies to be purchased to their shopping cart, and to check out—purchase the movies via credit card.


References


What to Turn In


Development Tool Constraints

In addition to the technologies used here—HTML, Java, JSP, sessions, servlets (deployed via Tomcat)—you may use client-side scripting or programming languages (e.g., Javascript, PHP, embedded Java, style sheets) as you find appropriate; you may use other or different server-side technologies with the instructor's permission. Your program must work with a postgreSQL database having the schema developed in Phase 1.


Functional Requirements

In an actual development effort, the functional and look-and-feel requirements for FabFlixs's customer functions would have been specified in every particular. We've purposely left these requirements high-level because we want you to use your skills, experience and reasoned judgment to refine the requirements. Do feel free to ask the instructor or TA for advice! With your project manager's permission, you can enhance these specifications for potential additional credit–but be careful: including additional features that do not work will detract from your score.

Overall, the system must (of course) behave as specified, but also have an appealing, easy-to-use, and consist user interface and appropriate error handling with specific and correct error messages and actions.


More about Tomcat and WAR Files

As discussed in Phase 0, Tomcat deploys WAR files. A WAR file is a compressed directory hierarchy, and actually is a Java "jar" file that meets additional requirements Tomcat lays down. To make a proper WAR file requires understanding the basics of this hierarchy; we describe these below, using the TomcatTest WAR file used in Phase 0 to illustrate.

You can look at the contents of TomcatTest. and WAR files in general, in a couple of ways:

Decompress the TomcatTest WAR; refer to the resulting directory hierarchy as you follow the discussion below to see how WAR files are "laid out."

The directory hierarchy for a WAR must have the following structure:


Creating a FabFlixs WAR File

The easiest way to make a FabFlixs WAR file is to use the TomcatTest directory hierarchy as a starting place. Make a copy of the hierarchy and change its root directory name to your team name. Update web.xml to reflect the name of your servlet, the descriptive name that is to appear on the Tomcat management page, and so on—what tags do what in this file is easy to determine from its comments and a bit of experimenting. Add and remove files as needed to contain your Phase 2 work. Compile your Java files (see the next paragraph), create a WAR (see the paragraph after that), tell Tomcat to deploy it (you use the same procedure as was used in Phase 0, except you give the name of your WAR) and then use a browser to access it (using the URL designations you gave in webinf.xml).

When you compile a java servlet program, you must include in the classpath the file servlet-api.jar. You will find this file in, among other places, the lib directory of the folder in which you installed Tomcat. The path is typically C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar. You will also need to include the postgreSQL JDBC jar you installed in Phase 0; if you have added it to your classpath, you need do nothing further. So, for example, to compile a Java program FabFlixs.java, with the JDBC jar already in the classpath, but the servlet jar not, you would issue the command (on one line)

javac -classpath "%CLASSPATH%;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar" FabFlixs.java

To package your hierarchy into a WAR, issue the following command from inside the root directory of your hierarchy: Creating the WAR from outside the root directory sometimes produces a WAR that, when deployed by Tomcat, does not provide a correct directory hierarchy.

jar -cvf filename.war .

Note the "." at the end of the line; that refers to the current directory. -cvf is "compress, being verbose when telling us what is going on, into a file with the name that immediately follows." That name is filename.war, and it is placed in the current directory. This is the WAR you tell Tomcat to deploy.

Since deployed Tomcat directories are accessible, if you need to fix a bug or make a change to your code (and you probably will!) you can do it directly in the deployed directory; make the change, recompile the code, and, since it's already deployed; just reload it using the Tomcat reload command, and you're ready to test it. Don't forget to reload because, if you do, Tomcat will use the original file, not the modified one. This approach is much easier than fixing the problem in the original directory hierarchy, recompiling it there, making a new WAR file, unloading the existing servlet and deploying the new WAR file. But do be careful: if you corrupt the structure of the deployed directory, you will need to remove the existing servlet and make and deploy a new WAR.


Demonstration

To prepare for the demo, have the WAR file you turned stored on your demonstration machine; also have the postgreSQL server up and running. When the demo begins, we will ask you to deploy the WAR file via Tomcat.

Demonstrate the correctness, completeness and performance of your customer functions. Your task is to convince us, in no more than 15 minutes, that your work is well and completely done and the FabFlixs project is ready to move to phase 3.

Written for ICS185 Winter 2005 as "Project 2" by Chen Li.
Revised by Norman Jacobson for ICS185 Spring 2005 by Norman Jacobson, March 2005.
Revised by Norman Jacobson to clarify some requirements, update links, and to add to
  and reorganize the information about Tomcat, March 2007.
  Incorporates some of information added to the Winter 2007 version of "Project 2" by Chen Li and Shengyue Ji.
Revised to include more detail and a clearer discussion on sale quantity and shipping
  address, and to reflect they are now stored in the sales table, by Norman Jacobson, September 2007.
Removed sorting by genres and stars within the movie list (too archane); now one genre
  is selected before movies are displayed (rather than all movies listed in genre order);
  login logic simplified; specs added for what to do if the movie or star poster is unavailable
  or invalid, by Norman Jacobson, December 2007.
Correction of minor typos, by Norman Jacobson, September & October 2008.
Added READ.ME file requirement, by Norman Jacobson, December 2008.
Minor updates to reflect postgreSQL 8.3.7, by Norman Jacobson, March 2009.