Java Reference
In-Depth Information
The Parameter radio button should be selected and the param keyword will be added to the first tag.
15.
Add the correct parameters for the remaining properties.
Be careful that you specify the correct EnterEmpInfoForm field name.
16.
Change to the Design view of DispEmpGrossJSP and click on Get Property (in the JSP
Tags tray).
17.
Click on the getEmpName expression icon.
The Insert JSP Get Property window will be displayed.
18.
At the Insert JSP Get Property window, specify EmpBean as the Bean name, empName as
the Property name, and then click OK.
A getProperty icon will be inserted after the expression icon.
19.
Display the source code for the expression and the new entered getProperty tag.
Even though the tag is lengthier, notice how much simpler the syntax is. There is no need for the page designer to
understand objects and reference variables, and, most enjoyably, say good-bye to parentheses!
However, you, as the programmer, need to understand that the tags in EnterEmpInfoJSP:
1.
Created an Employee object and defined it as a bean
2.
Defined the bean to be accessible by other objects that can access the request
3.
Set the Employee bean's properties to the entered values
20. Delete the getEmpName expression by clicking on the icon (in the Design view) and
pressing the Delete key.
Time to test.
21.
Run c9.EnterEmpInfoJSP on the server.
22.
Enter 999 for the employee number, select Display, and click the Submit button.
DispEmpInfoJSP should display 999 as the employee number and 2 for exemptions.
23.
Change to the Source view of DispEmpInfoJSP.
Delete the import="c9java.*" statement from the page directive and the following
scriptlet:
24.
<jsp:scriptlet> Employee emp;
EmpExtractor ee = new EmpExtractor();
emp = ee.getEmployeeInstance(request);
</jsp:scriptlet>
25.
In the Design view of DispEmpInfoJSP, replace each of the expressions with the
appropriate getProperty tag and save the source code.
This is a good time to test DispEmpInfoJSP.
26.
Run EnterEmpInfoJSP on the server, enter values for all the employee properties, select
display, and click the Submit button.
Verify that all the data entered on EnterEmpInfoJSP is displayed by DispEmpInfoJSP.
To finish the application, we need to replace the scriptlets in DispEmpGrossJSP and DispEmpTaxAmtJSP with
tags to access EmpBean.
Search WWH ::




Custom Search