The HTML produced by open parameters can contain dynamic elements such as dsp:valueof tags. The open parameters of one servlet bean can also include other servlet beans.

The following example specifies to display a list of students who live in a dormitory, and under each student name list registered courses. It does this by nesting ForEach servlet bean: the outer servlet bean displays the student names, and the inner servlet bean displays the courses.

<dsp:droplet name="/atg/dynamo/droplet/ForEach">
  <dsp:param bean="/dorms/Markley.students" name="array"/>
    <dsp:oparam name="output">
    <p><dsp:valueof param="element.lastName"/>&nbsp;,
       <dsp:valueof param="element.firstName"/>&nbsp;:</p>

     <dsp:droplet name="/atg/dynamo/droplet/ForEach">
       <dsp:param param="element.subjects" name="array"/>
         <dsp:oparam name="outputStart"> <ul>
         <dsp:oparam name="output">
           <li><dsp:valueof param="element"/> </li>
         </dsp:oparam>
         <dsp:oparm name="outputEnd"> </ul>
     </dsp:droplet>

    </dsp:oparam>
</dsp:droplet>

When this page is compiled, the following actions occur:

The previous example generates HTML as follows:

<p>Williams, Susan:</p>

<ul>
<li>Linguistics</li>
<li>Biology</li>
<li>Latin</li>
<li>Philosophy</li>
</ul>

<p>Thomas, Frank:</p>
<ul>
<li>Physics
<li>American History
<li>Psychology
<li>French
</ul>

...
Referencing parameters in outer servlet beans

Servlet bean parameters have scope only within the bean itself. When nesting occurs, the parameters within each bean are unaffected by corresponding parameters in the outer- and inner-nested beans. However, an inner bean can access the values of an outer bean parameter by using to define another parameter in the outer servlet bean, and setting it to the value of a parameter in the current bean that the inner beans can access.

For example, you can modify the JSP shown earlier and obtain similar output, as follows:

<dsp:droplet name="/atg/dynamo/droplet/ForEach">
  <dsp:param bean="/dorms/Markley.students" name="array"/>
    <dsp:oparam name="output">
    <dsp:setvalue param="outerElement" paramvalue="element"/>

    <dsp:droplet name="/atg/dynamo/droplet/ForEach">
    <dsp:param param="element.subjects" name="array"/>
       <dsp:oparam name="outputStart">
          <p><dsp:valueof param="outerElement.lastName"/>&nbsp;,
             <dsp:valueof param="outerElement.firstName"/>&nbsp;:</p>
          <ul>
          <dsp:oparam name="output">
            <li><dsp:valueof param="element"/> </li>
          </dsp:oparam>
       <dsp:oparm name="outputEnd"> </ul>
    </dsp:droplet>

    </dsp:oparam>
</dsp:droplet>
 
loading table of contents...