The previous example is hard-coded to display properties of the Student_01 component. You can modify this example so it displays properties of any component of class Student. This is typically done through a query string in the calling URL that contains the desired property value—obtained, for example, via a form—which is accessible to the JSP as a page parameter.

The following example obtains the page parameter StudentID and uses dsp:getvalueof to set the EL variable currentStudent. This parameter is used to access a specific Student component and use its subjects property to set the servlet bean’s array input parameter:

<dsp:param bean="/samples/Student1" name="currentStudent"/>
   <p>Student's name:  <dsp:valueof param=""/>
   <p>Student's age:  <dsp:valueof param="currentStudent.age"/>

   <dsp:droplet name="/atg/dynamo/droplet/ForEach">
     <dsp:param param="currentStudent.subjects" name="array"/>
     <dsp:oparam name="outputStart">
       <p>The student is registered for these courses:
     <dsp:oparam name="output">
       <li><dsp:valueof param="element"/></li>
     <dsp:oparm name="outputEnd">

Note: The currentStudent parameter is a page parameter available throughout the page. It is not a parameter of the servlet bean itself, although in this example it is used to set the value of the ForEach servlet bean’s array parameter. In this example, the value of the currentStudent parameter is set explicitly, but in an actual site you would typically set the parameter dynamically, based on values the user enters in a form, other pages visited, or other criteria.

loading table of contents...