CS 506 Assignment No 3 Solution Fall 2019
Assignment No. 03
SEMESTER Fall 2019
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:
- The assignment is submitted after due date.
- The assignment is not submitted in .zip/.rar format.
- The submitted assignment does not open or file is corrupted.
- 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.
- 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@example.com
Lectures Covered: This assignment covers Lecture # 1 – 30
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.
|Figure 1: Sample Login Page (index.html)|
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”.
|Figure 2: Sample Shopping Cart (ShoppingCartServlet.java)|
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.
|Figure 3: Sample Checkout Page (CheckOutServlet.java)|
|Figure 5: Folder “assets” under web directory|
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.
|Figure 4: Sample About Us Page (info.html)|
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
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.
Click Here For Solution File