How to capture variables from within iterate tag

Hi. Can someone please advise how I can capture a variable from within an iteration? I can output a value by using <bean:write property="prop" value="val"> etc, but how can I assign this value to, say, a String and use it in standard java? This is really bugging me, hope someone can help

Originally posted by Gez Hall: Hi. Can someone please advise how I can capture a variable from within an iteration? I can output a value by using <bean:write property="prop" value="val"> etc, but how can I assign this value to, say, a String and use it in standard java? This is really bugging me, hope someone can help

The iterate tag allows you to specify an id parameter for where to store the current item in the iteration. This variable name is used in the pageContext. So to get it, you can use pageContext.getAttribute("idString"). However, this returns Object, so you'll have to keep casting in mind--don't mix your object types too much!

"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.

The iterate tag allows you to specify an id parameter for where to store the current item in the iteration. This variable name is used in the pageContext. So to get it, you can use pageContext.getAttribute("idString"). However, this returns Object, so you'll have to keep casting in mind--don't mix your object types too much!

Hi, Using pageContext.getAttribute("idString") I am only able to retrieve the Iterator index value. How do I assign the value being retrieved in the current <bean:write name="emp" value="ename"> . Say I wish to assign ename to a variable.