The previous section demonstrated how a parameter can point to any object. Those objects might themselves have property values that you will want to access from a JSP.
For example, say that you wanted to print the age
and name
properties of some object, but you don’t know ahead of time what that object is. Presumably a pointer to that object would be passed as a parameter. Let’s say that the parameter will be called currentPerson
.
To print those properties of that parameter, all you need to do is this:
<dsp:valueof param="currentPerson.name"></dsp:valueof> is
<dsp:valueof param="currentPerson.age"></dsp:valueof> years old.
Notice how the dsp:param
tag looks like it always has, except that instead of naming a parameter, the tag names a specific property of a parameter.
This form of the dsp:param
tag can be used be used to set a parameter, using param=..
, or update a parameter with another parameter value as in:
<dsp:setvalue param="currentPerson.name" paramvalue="user1"/>
This tag sets the first parameter, currentPerson.name
, to the value in the second, user1
. The currentPerson
page parameter maps to a component: that component’s name property takes the string value of user1
. Elsewhere, you would have previously set currentPerson
:
<dsp:param name="currentPerson" bean="/db/personGetter.person">
The parameter might also be set through Java code, as outlined in the previous section.