Hi there,
The #foreach loop in velocity can iterate through the following java
Object types: Vector, Hashtable or an Array.
For you to display a key,value pair in your web page, the best thing is
to use a Hashtable (I can't remember if you can use a HashMap object
instead, try it!)
The code would look something like this
Hashtable hash = new Hashtable();
> CallableStatement cs = con.prepareCall("{call
> sp_ml_getglobalfilms}");
[quoted text clipped - 4 lines]
> String fid = rs.getString("film_id");
> String fname = rs.getString("film_name");
// Add key,value pair to Hashtable hash
hash.put( fid, fname );
}
// Then on to your context ctx:
ctx.put( "result", hash );
// result is the name to be used in the template file
// that is $result
// And on your velocity template file
> #foreach ($item in $result)
>
> <tr class="tableData">
<!-- displays the key -->
<td>$item</td>
<!-- displays the value -->
<td>$result.get($item)</td>
> </tr>
>
> #end
Hope this helps,
Fabricio.