Download presentation
Presentation is loading. Please wait.
1
© copyright Janson Industries 2011
In class assg 2 solution Create CustJSP: Access the Customer bean Display the customer info using bean tags Change Func2Servlet to create CustBean and redirect to CustJSP Chapter 9 © copyright Janson Industries 2011
2
© copyright Janson Industries 2011
Chapter 9 © copyright Janson Industries 2011
3
In Class Assg 2 - solution
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 language="java" contentType="text/html; charset=ISO " pageEncoding="ISO "%> <html> <head> <title>CustJSP</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO "> <meta name="GENERATOR" content="Rational® Application Developer for WebSphere® Software"> </head> <body>The customer name is: <jsp:getProperty name="CustBean" property="custName" /><br> The street is: <jsp:getProperty name="CustBean" property="shipToStreet" /><br> Chapter 9 © copyright Janson Industries 2011
4
In Class Assg 2 - solution
The city is: <jsp:getProperty name="CustBean" property="shipToCity" /><br> The state is: <jsp:getProperty name="CustBean" property="shipToState" /><br> The zip is: <jsp:getProperty name="CustBean" property="shipToZip" /><br> The contact person is: <jsp:getProperty name="CustBean" property="contactPerson" /><br> The phone number is: <jsp:getProperty name="CustBean" property="contactPhone" /><br> </body> </html> Chapter 9 © copyright Janson Industries 2011
5
In Class Assg 2 - solution
In Func2Servlet protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { co.setCustName(request.getParameter("CustName")); co.setShipToStreet(request.getParameter("Street")); co.setShipToCity(request.getParameter("City")); co.setShipToState(request.getParameter("State")); co.setShipToZip(request.getParameter("Zip")); co.setContactPerson(request.getParameter("ContactPerson")); co.setContactPhone(request.getParameter("PhoneNum")); HttpSession sess = request.getSession(); sess.setAttribute("CustBean", co); response.sendRedirect("CustJSP.jsp"); //CustServlet cs = new CustServlet(); //cs.doGet(request, response, co); } Chapter 9 © copyright Janson Industries 2011
6
© copyright Janson Industries 2011
Chapter 9 © copyright Janson Industries 2011
7
© copyright Janson Industries 2011
Chapter 9 © copyright Janson Industries 2011
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.