[Top] [Prev] [Next] [Bottom]

<jsp:setProperty>

Sets a property value or values in a Bean.

JSP Syntax

<jsp:setProperty
        name="beanInstanceName"
        {
            property= "*"   |
            property="propertyName" [ param="parameterName" ]   |
            property="propertyName" value="{string | <%= expression %>}"
        }
/>

Examples

<jsp:setProperty name="mybean" property="*" />
<jsp:setProperty name="mybean" property="username" />
<jsp:setProperty name="mybean" property="username" value="Steve" />

Description

The <jsp:setProperty> element sets the value of one or more properties in a Bean, using the Bean's setter methods. You must declare the Bean with <jsp:useBean> before you set a property value with <jsp:setProperty>. Because <jsp:useBean> and <jsp:setProperty> work together, the Bean instance names they use must match (that is, the value of name in <jsp:setProperty> and the value of id in <jsp:useBean> must be the same).

You can use <jsp:setProperty> to set property values in several ways:

Each method of setting property values has its own syntax, as described in the next section.

Attributes and Usage

See Also

Tips



[Top] [Prev] [Next] [Bottom]

Copyright © 1999, Sun Microsystems, Inc. All rights reserved.