Setting JavaBeans Component Properties

There are two ways to set JavaBeans component properties in a JSP page: with the jsp:setProperty element or with a scriptlet

<% beanName.setPropName(value); %> 

The syntax of the jsp:setProperty element depends on the source of the property value. Table 12-1 summarizes the various ways to set a property of a JavaBeans component using the jsp:setProperty element.

Table 12-1. Setting JavaBeans Component Properties
Value Source Element Syntax
String constant <jsp:setPropertyname="beanName "property="propName " value="string constant "/>
Request parameter <jsp:setPropertyname="beanName "property="propName " param="paramName "/>
Request parameter name matches bean property <jsp:setProperty name="beanName

Get J2EE™ Tutorial, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.