CS506 Assignment 3 Solution and Discussion
Please read the following instructions carefully before solving & submitting assignment:
• You are not allowed to use any other software/IDE except NetBeans IDE for this assignment development.
• The submission must be a complete NetBeans IDE project folder (which should contain complete source code; Java files, servlet files, html files, database file, xml files and builds etc.). After finalizing, compress it with Zip or RAR format, save with your own Student ID (e.g. bs1234567890.zip) and submit it at VU-LMS within due date.
• Your assignment should be in .zip /.rar format. Other file formats will not be accepted.
• No assignment will be accepted through email.
Rules for Marking:
It should be clear that your assignment will not get any credit if:
o The assignment is submitted after due date.
o The assignment is not submitted in .zip/.rar format.
o The submitted assignment does not open or file is corrupted.
o The assignment is fully or partially copied from other student or ditto copy from handouts or Internet; strict disciplinary action will be taken in this case.
o The submitted code is unable to compile/execute in NetBeans IDE; during evaluation, submitted code will be checked on NetBeans IDE. If unable to execute then ZERO marks will be awarded and no excuses will be accepted in this regard.
Note: Do not put any query on MDB regarding this assignment, if you have any query then email at [email protected]
Lectures Covered: This assignment covers Lecture # 1 - 30
GOOD LUCKDetailed Description:
You are required to deploy a basic web application using Apache Tomcat Server, named ShoppingCart, for a typical online shopping system. In which a customer can add/remove items to shopping cart and proceed to place order. The program should calculate total bill and display amount via web page. Further, all orders will be saved in a backend database using MS Access so that administrator could process accordingly.
The program should facilitate at least one user i.e. Customer. For this purpose, you have to develop an html page (index.html) which should contain a login form, as shown in figure 1.
The customer should be able to login by using student id (must be your own student id) as username and “vu” as password.
Now, write a Java Servlet named as LoginServlet.java that will receive submitted information from login form (i.e. index.html) and verify input values; whether entered values are correct or not. If authentication is invalid then print back a message “Invalid Username or Password”.
If customer credentials (i.e. username and password) are correct, jump to Shopping Cart Page (i.e. ShoppingCartServlet.java) which should list down all available products (i.e. products having one or more items), as shown in figure 2.
Here, customer can provide quantity of desired product/s and click on Check Out button. If no item is selected (i.e. no quantity is provided), then a message “Cart is empty” should be displayed.
On the other hand, if cart is not empty, Checkout Page (i.e. CheckOutServlet.java) should serve the customer by displaying total bill, shipping charges along with no. of products & items etc. and also provide an input field for shipping address, as shown in figure 3.
To place order, customer must provide shipping address and click on Place Order button. Before displaying message "Order has been placed successfully.”, the program must save order details (i.e. no. of items, subtotal, shipping charges, grand total, shipping address and selected products with quantity) in corresponding database tables. Further, need to maintain quantity of products in database so that customer could not see out of stock products in next shopping.
Button “Go Back” should take back on Shopping Cart Page. However, customer can sign out from system by pressing “Logout” button. In this case, web developer information (student id, name and email address) should be displayed via an HTML page (info.html), as shown in figure 4.
DatabaseHelper.java (must contain all database related code)
BSxxxxxxxx.accdb (must be same as your own VU student id)
Shipping Charges ($) = ((no. of Items / 5) + 1) * 0.5
Sample Data & Database Tables:
Tab. 1: Sample Products Data
# Name Price Quantity 1 Flour $18.00 20 2 Oil $19.00 50 3 Ghee $10.00 0 4 Sauce $22.00 40 5 Sugar $21.35 35 6 Salt $25.00 26 7 Daal $30.00 38 8 Rice $40.00 92 9 Pasta $97.00 63 10 Fruits $35.00 72 11 Dry Fruits $31.00 70 12 Tea $21.00 12 13 Coffee $38.00 9 14 Milk $10.00 10 15 Snacks $23.25 13 16 Dessert $15.50 22 17 Vegetables $17.45 52 18 Chicken $39.00 98 19 Beef $62.50 0 20 Frozen Food $19.20 30 21 Sea Food $81.00 29 22 Sweet $10.00 29 23 Cake $21.00 0 24 Yogurt $26.00 0 25 Pickle $30.00 41
Tab. 2: Products Table in MS Access Database
Tab. 3: Orders Table in MS Access Database
Tab. 4: Order Details Table in MS Access Database
To download and install of Tomcat Server, please watch;
To create a web application project in NetBeans IDE, please watch;
To add ucanaccess driver in a NetBeans project, please watch;
Important Things to Implement:
You have to provide separate pages, servlets, java files and database tables as guided above. Merging of two or more will result in deduction of marks.
You need to put database file in assets folder under NetBeans project web directory along with html pages, as shown in figure 5.
For storing/fetching data to/from database, you will need to use proper SQL queries.
You can use same Product and Cart Java classes as provided in assignment # 1 & 2 and also can make changes as required.
Java classes must have proper Data Members and Member Functions along with Constructors, Standard Setters and Getters etc.
Need to make sure that exceptions are managed properly throughout the program; especially NullPointerException, ClassNotFoundException, NumberFormatException and SQLException etc.
All images, tables and sample data, given in this document, are just for reference purpose only; you have to provide your own implementations. It is not required to be exactly the same.