All parameter values described so far are either Strings, or open parameters (whose values are of type Servlet). It is possible for parameters to be assigned values that are of other types, such as Vectors, arrays, or any other Java type. Earlier, you saw how arbitrary objects can be assigned to parameters through the DynamoHttpServletRequest.setParameter() method.

Arbitrary objects can also be assigned to parameter values by attaching the parameter values to object properties through JSP files. For example:

<dsp:droplet name="/test/counter">
  <dsp:param bean="/test/Person.age" name="maxcount"/>
  <dsp:oparam name="lineformat">
    <li>This is number <dsp:valueof param="number"/>

Here the parameter maxcount has been assigned a value from the age property of the /test/person component. Primitive types such as int, float, short, are converted automatically to the corresponding Java object types Integer, Float, Short, and so on. Because the age property is of type int, the resulting property value is of type Integer.

Parameters with arbitrary object values can be displayed using the dsp:valueof or paramvalue=... constructs, just as they are for String parameter values. You can also display arbitrary object values within an ATG servlet bean by calling DynamoHttpServletRequest.serviceParameter().

AN ATG servlet bean often needs to obtain the value of an object parameter without actually displaying that parameter. For example, an ATG servlet bean might use the maxcount parameter to specify some sort of limit.

The HttpServletRequest.getParameter() method is not suitable for this because it can only access parameters that are of type String. To access arbitrary objects, you must use another method from DynamoHttpServletRequest called getObjectParameter(). For example:

public void service (DynamoHttpServletRequest request,
                     DynamoHttpServletResponse response)
     throws ServletException, IOException
  ServletOutputStream out = response.getOutputStream ();

  int maxcount = 0;
  Object maxcountval = request.getObjectParameter ("maxcount");
  if (maxcountval instanceof Integer)
    maxcount = ((Integer) maxcountval).intValue ();

  for (int i = 0; i < maxcount; i++) {
    request.setParameter ("number", new Integer (i));
    request.serviceParameter ("lineformat", request, response);

In this example, the maxcount parameter, assigned to an integer property, is used to specify the upper bound for counting.

loading table of contents...