Name

<jsp:setProperty>

Synopsis

The <jsp:setProperty> action sets the value of one or more bean properties.

Syntax

<jsp:setProperty name="beanVariableName" property="propertyName"
  [param="parameterName" | value="value"] />

Attributes

Attribute name

Java type

Dynamic value accepted

Description

name
String

No

The name assigned to a bean in one of the JSP scopes.

property
String

No

The name of the bean’s property to set or an asterisk (*) to set all properties with name matching request parameters.

param
String

No

The name of a request parameter that holds the value to use for the specified property. If omitted, the parameter name and the property name must be the same.

value

See below

Yes

An explicit value to assign to the property. This attribute can’t be combined with the param attribute.

The property type can be any valid Java type, including primitive types and arrays (i.e., an indexed property). If a runtime attribute value is specified by the value attribute as a Java expression, the type of the expression must match the property’s type.

If the value is a String, either in the form of a request parameter value or explicitly specified by the value attribute, it’s converted to the property’s type as follows:

Property type

Conversion method

boolean or Boolean

Boolean.valueOf(String), false for an empty string

byte or Byte

Byte.valueOf(String), 0 for an empty string

char or Character

String.charAt(0), 0 for an empty string

double or Double

Double.valueOf(String) ...

Get JavaServer Pages, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.