Homework 3
CS320, Spring 2004


Due: Wednesday April 28

Please upload your servlet class files to your ~/public_html/WEB-INF/classes directory on the server cs.calstatela.edu, and send the URL to the Shop servlet, presumably http://cs.calstatela.edu:8280/~username/servlet/Shop, to csun@calstatela.edu. Please also include the servlet java files and the text files from Ex.1 in the email as attachments. Make sure to use CS320 Spring 04 HW3 as the subject of the email, and include in the email your name so I don't have to guess names from email addresses.



1. [Products] (10pt)  Now it is time to populate your online store with some product information. The requirements regarding the product from Homework 1 still hold, and in addition:
Store your product information in a text file or multiple text files. The format of the file is entirely up to you. However, considering that in later assignments you'll need to import the file(s) into a MySQL database, it might be easier to use a tab-delimited format. For example, suppose I have the following categories/attributes for my product:

CPU
ProductID, Brand, Frequency, Price, Quantity
Motherboard
ProductID, Brand, Chipset, Description, Price, Quantity
Hard Drive
ProductID, Brand, Size, RPM, InterfaceType, Price, Quantity

I'll have three files cpu.txt, motherboard.txt, and harddrive.txt. The file cpu.txt would look like the following

ProductID\tBrand\tFrequency\tPrice\tQuantity
CPU-001001\tIntel Pentium 4\t2.8 GHz\t248\t10
CPU-001201\tIntel Pentium 4\t3.0 GHz\t300\t0
... ...
CPU-00200\tNULL\t0.8 GHz\t45\t1
CPU-00235\tAMD AthlonXP\t3.0 GHz\t200\5

2. [Servlet] Write a Java servlet Shop.java which provides the following functions:
When a user click on the Search button, the servlet should display all items in the Table under the selected category which match the search string. An item matches a search string if any attribute of the item contains the search string as a substring, case-insensitive. When a user click on the Browse button, the servlet should display all items under the selected category.