Java Reference
In-Depth Information
In c11/EnterShipInfoJSP before the form, insert an if tag with a test that checks if the
request type is a post.
12.
13.
Change c11/EnterShipInfoJSP, so that if the request is a post, the crtShipBean tags are
executed with the source attribute specified as request . (Make sure the tags prefixes are
TNT.)
14.
Change c11/EnterShipInfoJSP, so that after the ShipBean is created the insShip tags are
executed and a JSP forward to ConfirmIns.jsp is executed.
The Shipment application never had an extractor class (as the employee application did). Therefore, the
CrtShipBean class will perform that function (i.e., retrieve the Shipment information from the request and populate
the Shipment object properties). The Java Resources/ src/c11/CrtShipBean's doStartTag method needs to be
overridden to do the following:
If the source attribute is equal to request:
A.
Create a null Shipment object.
B.
Retrieve the shipment information (from the request parameter values) and set the
appropriate shipment properties.
If the source attribute is equal to database:
A. Create a Shipment object using the shipment number entered in shipNumTF
Then, in either case, define the Shipment object as a session attribute called ShipBean.
15.
To do the above, add the following class variables definitions to CrtShipBean:
private String source = null ;
Shipment ship;
16.
Create a getter and setter for the variable source.
17.
Override the doStartTag method and add the following statements to the doStartTag
method:
if (source == "request"){
ship = new Shipment();
ship.setShipmentNum(pageContext.getRequest().getParameter("shipNumTF").toString());
ship.setSupplierName(pageContext.getRequest().getParameter("suppNameTF").toString());
ship.setRcvMon(pageContext.getRequest().getParameter("MonthDDM").toString());
ship.setRcvDay(pageContext.getRequest().getParameter("DayDDM").toString());
ship.setRcvYear(pageContext.getRequest().getParameter("YearDDM").toString());
ship.setRcvHour(pageContext.getRequest().getParameter("HourDDM").toString());
ship.setRcvMin(pageContext.getRequest().getParameter("MinuteDDM").toString());
ship.setRcvAMPM(pageContext.getRequest().getParameter("AMPMDDM").toString());
ship.setEmployeeNum(pageContext.getRequest().getParameter("empNumTF").toString()); }
if (source == "database"){
ship = new Shipment(pageContext.getRequest().getParameter(" shipNumTF").toString()); }
pageContext.getSession().setAttribute("ShipBean", ship);
18.
Override the Java Resources/src/c11/InsertShip doStartTag method to get the ShipBean
(using the PageContext object) and execute its doInsert method.
Search WWH ::




Custom Search