dsp:getvalueof lets you save a JavaBean component, Page parameter, or Static value to a variable in the specified scope. Other tags such as dsp:valueof can then reference that value. The variable is also accessible to the JSP Expression Language.

dsp:getvalueof has the following syntax:

<dsp:getvalueof
   source-value var="var-name" [scope="scope-spec"] ] >
</getvalueof>

where source-value specifies the value source as a JavaBean component, Page parameter, or Static value:

  • bean="nucleus-path/component-name"

  • param="param-name"

  • value="static-value"

JavaBean component

dsp:getvalueof can make JavaBean components available to EL. The following dsp:getvalueof tag sets the student variable to the Nucleus component /atg/samples/Student_01. The tag omits the scope attribute, so the default pageScope is applied:

<dsp:getvalueof bean="/atg/samples/Student_01" var="student"></dsp:getvalueof>

The student variable provides access on the current JSP to all Student_01 component properties. For example, you can use EL to render this component’s age property:

You are <c:out value="${student.age}"/> years old.

Page parameter

dsp:getvalueof can make page parameters available to EL. In the next example, dsp:getvalueof sets the requestScope variable gender to reference the page parameter sex:

<dsp:getvalueof param="sex" var="gender" scope="request"> </dsp:getvalueof>

After you set this variable, it is accessible to other objects in the same request scope. In the following example, the c:when tag evaluates requestScope.gender in order to determine which content to display:

<c:choose>
   <c:when test="${gender == "female"}"/>
      Formal dresses are on sale!
   </c:when>

   <c:when test="${gender == "male"}">
      Tuxedos are on sale!
   <c:when>
</c:choose>
Static value

dsp:getvalueof can save a static value to an EL variable, as in the following example:

<dsp:getvalueof value="student" var="userType"> </dsp:getvalueof>

Subsequent references to the userType variable resolve to the literal string student.


Copyright © 1997, 2012 Oracle and/or its affiliates. All rights reserved.

Legal Notices