In this assignment you are to add the following functionality to your online store:
(3%) Add Items
You will create a set of pages that will allow an administrator to add items to your site. You are to use the Model-View-Controller (MVC) architecture to implement this functionality. You are to create a controller (servlet) named "AddItems". It will determine whether the user is logged in as an administrator. If the user is not logged in, the use should be redirected to the Login page. If the user is logged in, but is not an administrator, the user should be forwarded to an Error.jsp page (View). If the user is logged in as an administrator, the user should be forwarded to an AddItems.jsp page (View). Note that the user should not be allowed to directly request the Error.jsp or AddItems.jsp pages. To enforce this, they should be placed within a sub-directory in your application's WEB-INF directory.
The AddItems view should prompt the admin for an item name, description, price, and quantity. All fields are required, and the quantity field should be a whole number. All data should be submitted to the AddItems controller. If an error occurs, the admin should be forwarded to the AddItems view, and an error message should be displayed. If all fields validate, a new item should be added to the store, and the AddItems view should be displayed with a message indicating that the item was accepted.
You can assume that no two items will be submitted with the same name.
Items should be represented with an Item Bean Class. This class should contain all necessary getters and setters to access and set item data.
Registered users will be allowed to browse the items for sale on your site, and add them to their cart. To implement this functionality you should create a Browse controller. This controller will ensure that the user is logged in. If the user is not logged in, the user should be redirected to the Login page. If the user is logged in, the controller should access your data store, and create/get a reference to a collection of Item beans. These Item Beans should then be forwarded to a Shop.jsp page (view). All items should be displayed in tabular form, with a link allowing the user to add the item to their shopping cart.
(3%) Shopping Cart
Upon clicking an "Add to Cart" link on the Browse page of your site, the user should be redirected to a Shopping Cart controller that will add the specified item to the user's cart. After the item has been successfully added to the cart, the user should be forwarded to a ShoppingCart.jsp (view) that will display all items currently in the user's cart. The view should also display the total cost of all items in the cart.
From the ShoppingCart view, a user will have the option to continue shopping or checkout. If the user decides to continue shopping, they should be redirected back to the Browse page. If the user decides to checkout, the quantities of items in your store should be updated to reflect the sale of all items in the current users cart. After they have been updated, the user should be redirected to a page informing them that their order has been placed, and their items will ship soon.
(3%) View Orders
The view orders page will list all orders that have been completed. The orders should be displayed in tabular form, and an itemized list of all items should be displayed, along with an order total. You should also include the user's information (name, address, etc...) with each order.
Total: 12% of overall grade.
Note that you should use MVC architecture in every aspect of this assignment. Utilize beans to communicate data between controllers and views. If you do not use MVC you will not receive any credit for this assignemnt.
November 25, 2009 - 11:59pm
Now that you've created a registration page, you must create a method for allowing users to log into your e-commerce site. To do so you will need to create a JSP Login page. The page layout should be as follows:
Your Login.jsp page should submit all form data to an Authenticate servlet. The Authenticate servlet will search all registered users in an attempt to match the submitted username and password. If no user is found that matches the submitted username and password, the servlet should redirect the user back to the login page. If redirected back to the login page, an error message should be displayed as shown below:
If the user successfully authenticates, that is to say, the submitted username and password matches a registered user, then the Authenticate servlet should create session variables to store the User's first name, last name, and e-mail address. Furthermore, the Authenticate servlet should redirect the authenticated user to a Welcome.jsp page. The Welcome.jsp page should read the User's first name from the session, and display the following page (assuming that a user with a first name 'John' successfully logged in):
Notice the logout link next to the User's name. Upon clicking the logout link the user should be directed back to the Login.jsp page and all session variables should be unset.
If a user attempts to visit the Welcome.jsp page before authenticating, or after logging out, the Welcome page should immediately send the user back to the Login page. That is to say that only user's who are logged in can view the Welcome page. If a user is sent back to the Login page due to lack of authentication, the Login page should display the following message:
(1.0%) Login.jsp layout
(1.0%) Login.jsp error messages
(1.0%) Authenticate servlet correctly authenticates users and creates session values
(1.0%) Welcome.jsp layout and functionality
Total: 4% of overall grade
When grading, the following usernames and passwords should be valid:
For this assignment you should automatically create these users using a Setup servlet. This Setup servlet will create all required users as if they had successfullyl registered. Be sure to include a link to this Setup servlet in your Assignments.html file when submitting your work to CSNS. Without it, your application can not be tested and you will receive a grade of zero (0) for the assignment, no matter how correct your work actually is.
As usual, submit all java, jsp, css, js, and image files to the CSNS Website along with an Assignments.html file linking directly to each of your three pages in this assignment. Lastly, be sure to deploy your working Web Application on the CS3 server prior to the due date/time. And files submitted after the due date/time will be considered late and not be graded, no matter how "close" to the deadline they were actually submitted.
Use the following files as HTML references:
All html, css, and image files can be downloaded here.
November 2, 2009 - 11:59pm
This quarter we will develop an E-Commerce Website to facilitate the sale of CSULA merchandise. This site will be developed incrementally, with the first installment being a registration page.
A visitor must have a valid account in order to shop on your site. To create an account, a visitor must register using the following form:
The registration form should be a servlet named Register, and the action of the form should also be Register. That is to say, the form will submit all form data to itself. Upon submission, your servlet should verify the following:
- The first name, last name, street 1, city, zip, phone, e-mail, and password fields are all populated.
- A state has been selected.
- The zip field contains a 5-digit number.
- The first two phone fields contain exactly 3 numbers, and the last contains 4 numbers.
- The e-mail field contains a valid e-mail address.
- Both password fields are equal and contain at least one letter and number, and has a minimum length of 6 characters.
If an error occurs during validation, your servlet should re-display the form with an error message next to each field that contains an error. For example, if the user did not submit a first name, the following should be displayed:
If an error occurs during validation and the form is redisplayed, all fields that contained valid data should automatically be populated with the submitted data. In other words, a user should not have to re-type data. Instead, your servlet should use sticky forms.
If all fields validate then your servlet should display the following:
Upon successful registration your servlet should create a new User object and add it to a list of users stored in the Servlet Context. Use the following User Class in your implementation:
In addition to your registration page you should create the following administrative page titled ViewUsers:
This page should display a table of all users, and their information, currently registered on your site. Note the column names and formatting of the data in each column.
All CSS and image files necessary to complete the assignment, as well as sample HTML files can be found in the zip file below:
1.5% - Validation
1.0% - Presentation
1.0% - Sticky Forms
1.5% - Admin Page
Total: 5% of overall grade
October 19, 2009 - 11:59pm
CSNS All files must be submitted to CSNS prior to the due date/time.