Reference no: EM132268840
Java EE Programming Assignment - Dynamic Web Application with Servlets, JSP, JSTL and EL
Overview - In Assignment, you create a Web Application to perform CRUD operations on a data structure that stores information about customers. Unlike a more realistic examples, no database is involved: the customer, account and address information is stored in memory and accessed by the class CustomerManager from assignment 1 and 2.
Users can add customers and lookup customer information by selecting customer's account number from a list. Users can also delete and update a customer.
Instructions -
1. Get the start-up code by downloading the file Assignment3StartupWeb.war from eCentennial under Student Activities -> Assignments.
2. Open Eclipse. Using a new workspace is recommended.
a. Work in the Java EE perspective or the Web perspective.
b. If your workspace does not already have one, create a new Wildfly server.
c. Make sure your Wildfly server starts successfully.
3. Import the startup WAR. During the import:
a. Change the Web project name to include your group name. For example, for group called ABC, the project should be called Assignment3_ABC_Web.
b. Specify target runtime Wildfly.
c. Do not add your WAR to an EAR.
d. When the import is complete, verify that your Web project has packages of Java classes.
4. Look at the code you are given. Package assignment3.dto contains three data transfer objects and package assignment3.data contains model layer class.
Take note of public methods in the model layer because your servlets must call them.
a. Class Customer is a JavaBean that represents one customer. The Customer class has fields accountNo, name, mobilePhone, homePhone, emailAddress, status, account, address. Note that account and address fields are also collections, which says a customer can have multiple accounts and addresses. The Customer class also has a default constructor that takes all arguments and it has the standard methods such as toString(), hashCode() and equals().
b. Class CustomerManager is a singleton that stores customer information in memory a data structure of type Map<String, Customer>. In addition to public CRUD methods getCustomer(), addCustomer(), deleteCustomer() and updateCustomer(), getgetAllCustomers() public method returns a Collection that holds all customers.
5. Create a welcome page, index.jsp.
a) This page should have a button or link to add a customer.
b) This page should display all Customers in a tabular format and users should be able select them to view, delete or update.
6. Create the page addCustomer.jsp.
a. Design of this page is up to your imagination. You can either get Account and Address information on the same page where you get customer information or you can create separate jsp pages to collect Account and Address data. However, if you create separate pages, you need to make sure that account and address belong to the same customer you are trying to add. Use AccountNo to connect them. Your UI design should allow end user to add as many Address and Account as possible. In order words, your page should be dynamic to accept multiple addresses and accounts.
b. If the user clicks Add, a servlet creates a new Customer object and adds it to the data structure. If the user clicks Cancel, the servlet responds with index.jsp. Keep in mind Customer object would have Address and Account collections.
7. Write a servlet to process the add-customer form.
a. Put all servlets in a Java package called assignment3.servlets.
b. Later, you will add exception handling for user-input errors. For now, assume users always enter valid data.
c. When done, the servlet returns the user to index.jsp.
a. Decide what scope customers should be stored in. Consider the following:
i. This Web application has no log-in and customer objects have no associated owner.
ii. The deployed application may be made available to many people.
b. You can't avoid duplicating some of the information also stored in class Customer but minimize the amount of data stored outside the model-layer. You should NOT have more than one customer with the same account number.
c. Use <href> tag also to display one link for each stored customer. Ideally, the link (URL) should include Customer account number so that users can click on it.
8. Write a servlet to get customer information when the user clicks customer's account on index.jsp. The servlet then responds to the user with a JSP page that shows details of a customer.
9. Create showCustomer.jsp JSP page to display customer details.
a. The display- customer JSP page may look similar to the add- customer form where data values can be edited except account number.
b. If the user clicks Cancel, the servlet redisplays index.jsp.
c. If the user clicks Update, a servlet updates the customer form the data structure and then redisplays index.jsp.
d. If the user clicks Delete, a servlet deletes the customer form the data structure and then redisplays index.jsp.
10. Test and make sure users can add, update and delete customers.
a. Do new customers appear on index.jsp when customers are added?
b. Do new names disappear from index.jsp when customers are deleted?
c. Do you see updated values on index.jsp when customers are updated?
d. When the happy path works, (the application handles all good user input) export your project to a WAR.
11. Add error handling. Handle exceptions the following ways:
a. To report a CustomerNotFoundException or a DuplicateCustomerException, write another JSP page to display error messages.
i. A CustomerNotFoundException should never occur if your code is working properly but allow write the JSP page so that one page can display a variety of messages.
ii. The error page must include a link to index.jsp so the user can try again.
b. When users submit the add-customer form with missing or invalid information, exceptions of type CustomerDataException should occur. In this situation, use the fact that JSP expressions that evaluate to null are not displayed.
i. Modify the add-customer servlet to redisplay the add- customer input form after a CustomerDataException occurs.
ii. Pass the exception message back to the JSP. Also pass the values that the user entered previously so that the user can see the error.
iii. Add expressions to the add- customer form to display the error message (if there is one) and to display what the user typed previously into the entry fields.
12. When you are ready to submit, export your Web project into a WAR and call the file with your group name such as Assignment3_ABC_Web.war.
a. To make sure your solution includes source, do one of:
i. Import your WAR back into your workspace but into a new Web project with a different name. Check that the new project contains all your files including Java source.
ii. Open your WAR with a utility such as WinRAR or WinZip. Look for files with extension .java in folder \WEB-INF\classes\assignment3\servlets.
b. Remove all projects from the server and stop the server before you exit from Eclipse.
13. Upload your WAR file along with README file to the Assignment folder under Assessments on eCentennial. Double check that your WAR file includes java files as well.
Attachment:- Assignment Files.rar