<jsp:setProperty>

The <jsp:setProperty> action sets the value of one or more bean properties. It supports the attributes described in Table 1-9.

Table 1-9. Attributes for <jsp:setProperty>

Name

Java type

Request-time value accepted

Description

name

String

no

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

property

String

no

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

param

String

no

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

value

See below

yes

Optional. An explicit value to assign to the property. This attribute cannot 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 the value attribute specifies a runtime attribute value, 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 is converted to the property’s type as described in Table 1-10.

Table 1-10. Conversion of string value to property type

Property type

Conversion method

boolean or Boolean

Boolean.valueOf(String)

byte or Byte

Byte.valueOf(String)

char or Character

String.charAt(int)

double or Double

Double.valueOf(String) ...

Get JavaServer Pages Pocket Reference 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.