Part I - Modify your DisplayAccount.jsp from Lab #7. In Lab #7, your AccountLookupServlet used the Account
Question:
Part I - Modify your DisplayAccount.jsp from Lab #7. In Lab #7, your AccountLookupServlet used the Account object to lookup one Account and then passed control to the DisplayAccount.jsp which used scriptlet tags to display the Account info. In this Lab use the UseBean/GetProperty tags to display the Account info. (15 points only)
OR
(Part A & Part B = 40 Points)
Part A - Modify your AccountLookup.html file, from Lab #2. Add one new item to this HTML file. Add a link that says: "View All Accounts". Make it so when the user clicks this link, it will go to the DisplayAccounts.jsp. We will build this JSP in Part B, below.
Below is the AccountLookup.html
Account Lookup
AcctNo: CustomerID: Type: Balance:Part B - Now criate a new JSP, called DisplayAccounts.jsp. This JSP will be different than the AccountLookup.jsp that we built in Lab #7. This JSP should get the Customer object out of the Session. This Customer Object should contain the AccountList object that holds a list of Accounts. Then using scriptlet tags, display a table of all the accounts for the customer that logs in.
Below is=AccountLookup.jsp import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class LoginServlet extends HttpServlet { public void doGet ( HttpServletRequest req, HttpServletResponse res ) throws ServletException, IOException { String message, user, pw; String nextURL; //Get the user name and password from the HTML Form user = req.getParameter("uname"); pw = req.getParameter("pw"); System.out.println("Received the user name " + user + " and password of " + pw);
//Get the Customer information from the database using the Customer Business Object. Customer aCustomer = new Customer(); aCustomer.setUserName(req.getParameter("uname")); aCustomer.setPassword(req.getParameter("pw")); //Check that the pw from the DB is the same as the one from the HTML Form if (aCustomer.getPassword().equals(pw)) { //If the pw is correct, creeate a Session object HttpSession session = req.getSession(); //Put the Customer Business Object in the Session object session.setAttribute("customer", aCustomer); //Use the RequestDispatcher to forward control to the AccountLookup Servlet nextURL = "/Lab7/AccountLookupServlet"; } else { //If the pw is incorrect, use the RequestDispatcher to forward control to the ErrorPage Servlet nextURL = "/Lab7/ErrorPage.jsp"; } //Send the user to the next page res.sendRedirect(nextURL); } }
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill