WCD-LAB @HOME 7-Ans
2
Use the jsp:useBean. setProperty. and getProperty tags.
Preparation
No preparation is needed for this exercise.
Task - Investigate the jsp:useBean Tag
1. Open the project called SL314m071ab2 in the d:\labs\student\exercises directory.
2. Examine the index, jsp page. This contains a form that triggers the setAddress. jsp page and submits five parameters to that page.
3. Examine the class domain.Address. This is a simple JavaBean that holds address information. Notice that the field names declared in the form and the attribute names of the Java Bean are similar but not identical.
4. Create a new JSP. called setAddress. jsp.
5. Add code to the setAddress. jsp to use the <jsp: useBean> tag to create a JavaBean.
6. In the seLA.ddress.jsp add code using the <jsp: setProperty> tag to populate all the fields of the addressBean directly from the input properties. If you are in doubt, refer to the section under the heading "The setProperty Tag" section in Module 7 of the student guide.
7. Add an unordered list, and in it. print out each element of the bean using the <jsp:getProperty> tag.
S. Create a second unordered list, and in it. print out each element of the bean using scriptlet code. Recall from "The useBean Tag" section in Module 7 of the student guide that the <jsp: use Bean > tag creates a variable in the generated sen-let code. That variable has the name provided in the id element of the <jsp:useBean> tag.
9. Test your application and determine that the data are transferred from the form into the bean and are then displayed by the set Address, jsp page.
Task - Retrieve Session Information Using JSP Tags
1. Create a new page called showAddress .jsp.
2. Using elements of the showAddress. jsp page for assistance, create a standalone page that shows the current values of a bean called addressBean that is in the session scope. Note that this page will be loaded by typing its URL directly. The goal is to demonstrate that the bean created in the previous task is still accessible because it is in the session scope.
3. Test the page to show the values from the previous form submission.
Preparation
No preparation is needed for this exercise.
Task - Investigate the jsp:useBean Tag
1. Open the project called SL314m071ab2 in the d:\labs\student\exercises directory.
2. Examine the index, jsp page. This contains a form that triggers the setAddress. jsp page and submits five parameters to that page.
3. Examine the class domain.Address. This is a simple JavaBean that holds address information. Notice that the field names declared in the form and the attribute names of the Java Bean are similar but not identical.
4. Create a new JSP. called setAddress. jsp.
5. Add code to the setAddress. jsp to use the <jsp: useBean> tag to create a JavaBean.
6. In the seLA.ddress.jsp add code using the <jsp: setProperty> tag to populate all the fields of the addressBean directly from the input properties. If you are in doubt, refer to the section under the heading "The setProperty Tag" section in Module 7 of the student guide.
7. Add an unordered list, and in it. print out each element of the bean using the <jsp:getProperty> tag.
S. Create a second unordered list, and in it. print out each element of the bean using scriptlet code. Recall from "The useBean Tag" section in Module 7 of the student guide that the <jsp: use Bean > tag creates a variable in the generated sen-let code. That variable has the name provided in the id element of the <jsp:useBean> tag.
9. Test your application and determine that the data are transferred from the form into the bean and are then displayed by the set Address, jsp page.
Task - Retrieve Session Information Using JSP Tags
1. Create a new page called showAddress .jsp.
2. Using elements of the showAddress. jsp page for assistance, create a standalone page that shows the current values of a bean called addressBean that is in the session scope. Note that this page will be loaded by typing its URL directly. The goal is to demonstrate that the bean created in the previous task is still accessible because it is in the session scope.
3. Test the page to show the values from the previous form submission.
No comments:
Post a Comment