O'Reilly logo

JavaServer Pages, Second Edition by Hans Bergsten

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 the next table

RT expression

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, 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)

byte or Byte

Byte.valueOf(String)

char or Character

String.charAt(0)

double or Double

Double.valueOf(String)

int or Integer

Integer.valueOf(String)

float or ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required