Java Reference
In-Depth Information
The Bean Name drop-down options show all valid beans in the page, the value for
this field must match the bean's ID from the <jsp:useBean> tag. After we select one
the Property Name drop-down is populated with all properties in the bean. Once we
select the appropriate bean and property, NetBeans generates the following markup
code:
<jsp:getProperty name="surveyData" property="fullName" />
The value of the name attribute matches the value we selected in the Bean Name
drop-down, and the value of the property attribute matches the values selected
in the Property Name drop-down.
The last change we need to make to the page is to modify the scriptlet so that the
array containing the programming languages selected by the user is obtained from
the bean instead of directly from the HTTP request.
To accomplish this, the line:
String[] selectedLanguages =
request.getParameterValues("progLang");
Needs to be changed to:
String[] selectedLanguages =
surveyData.getProgLangList();
Notice that the bean's ID (surveyData, in our case) can be used in scriptlets as a
variable name.
After implementing all of the above changes, our output page now looks like this:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="surveyData" type="com.ensode.nbbook.model.SurveyData"
scope="request"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>Thank You!</title>
</head>
<body>
<h2>Thanks for taking our survey</h2>
<p>
<jsp:getProperty name="surveyData"
 
Search WWH ::




Custom Search