Homework 4: Shopping cart, Java Servlets, JDBC You are going to ...

drivercutInternet και Εφαρμογές Web

13 Νοε 2013 (πριν από 8 χρόνια και 1 μήνα)

423 εμφανίσεις

Homework 4: Shopping cart, Java Servlets, JDBC
You are going to complete your eCommerce site using scripts to communicate with the back-end. The

following are accepted:
Java Servlets
In case you want to use JSP and Java Servlets you will have to install the JDBC connector as well as

the JWS Web server to support them. Although the installation may seem very involved, it is actually

quite simple. In addition, JSP is very simple to use and Java Servlets look exactly the same as writing a

Java program. The instructions to install the Java Webserver and the instructions to install the JDBC

drivers can be found on the class website.
Perl is already installed on the csci571 server so you don't need to install anything. You can just

proceed with implementing the scripts that retrieve as well as update the back-end DB.
PHP requires installation. I am working on the guide and I will post it shortly. In the meantime there is

plenty of information on the web to get started.
NOTE: No matter which technology you want to use make sure that you keep backups of

anything that you may edit especially shell files (.cshrc, .bashrc, etc)

You should have a login/registration html page that asks for the information you are storing in the

user table. Use client side cookies to recognize the user when he revisits your site. You may have to

enable the cookies in your browser. The Customer table should have fields for the name, etc and

whatever else you find useful. One field must be key. You can use the name or some ID as the key. Use

more than one different kind of form entry field.e.g. name-text, phone-numbers, etc Use Javascript to

verify the fields before submitting them. Don't make all the fields the same type, e.g., his name should

be a string, his age a sensible number. Don't worry about a realistic set of user data.

If the user is a new one, add him to your database. e.g. INSERT VALUES....

After successful registration, show him your product/catalog page. The catalog should be created

from your Product table with fields for product id (the key field), description, photo, price, number of

this product left in stock, etc. In this assignment, every time the user buys something, the information

should be passed back to the server. Thus, if I buy something you should subtract one from the quantity

in the database. Also, the next time I go to the product page I shouldn't be able to purchase the same

product since it is out of stock. You can just disable the “Add to cart” button in that case and show a

note “Out of stock”.


The server script will maintain a shopping cart of information. Write the

shopping cart code on your own don't download one from the internet. There are many ways to

implement a shopping cart. You could use the servlet HttpSession object. This is extra credit and not

much information will be provided. You can do your own research for this.

The catalog page should

have a “Show Cart” button. Your server code should aggregate purchases by product type, i.e., if the

user buys one Book1, then buys another Book1, the Show Cart entry for Book1 should show that the

user bought 2 of them.

When the user selects “Done Shopping”, you should check if he is logged in or not. If not then you

should go first to the login page. On successful registration or login, you should display an invoice

page on the server, update the Product table, update the Sales table, and send back an invoice.


Create an
Inventory table which has fields for product id (linked to the product

table), number in inventory, place of inventory. Products may appear more than once in this table since

they may be at different inventory locations (that's the point). You should create multiple entries for the

same product and you should update them correctly, you'll get extra credit please let the TA know in

your readme file that you've done this so they can test it. To clarify, if I am a registered customer from

California and I purchase a product which is available in California as well as New York you should

decrease the quantity of the California entry since its in the same state.

If you implemented your user interface to be a single “Add to cart and checkout” button push to get

one product, i.e., you have no “number of items to buy” field, then you must have your product

quantities be very low (like 2 or 3), so that the TAs can test whether you handle this correctly.

The Sales table has fields for customer id (linked to customer table), product purchased, and the rest

of the information you used to generate the invoice. Have a button somewhere in your application that

allows the user to see his full sales history, i.e, every invoice you've ever created for him/her.
Additional requirements:

You may use any combination of JSP and servlets,PHP, Perl.

All your pages should use external cascading style sheets.
In addition you should create a webpage called admin_control_panel.html with buttons that do the


erases, creates and
initializes all you database tables to some initial data that it reads in from files or

hard coded values. (You have to have something like this anyways to do your normal testing). This is

exactly what you have submitted for homework 2( the SQL text file).

prints all the data in you data base. This is exactly what you submitted for homework 2(the print DB

script so that we can verify that the changes are getting through to the back-end DB).
SUBMISSION: Through the Digital Dropbox, Blackboard. You should submit ALL your HTML,

CSS, scripts and everything you have used to create the website as well as the README file.

Please submit a ZIP file.