Link to home
Start Free TrialLog in
Avatar of corduroy9
corduroy9

asked on

Create array

In JSP I'm trying to create an array.  I've been trying to use <c:set var='items' value='stuff' />

like in a for loop and keeping setting var but i don't think thats working.  How should i go about this?
ASKER CERTIFIED SOLUTION
Avatar of Kuldeepchaturvedi
Kuldeepchaturvedi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
try it with the setArray:

<c:setArray var="row" index="0" value="0"/>
<c:setArray var="row" index="1" value="1"/>
<c:setArray var="myArray" index="0" value="${row}"/>

<c:out value="${myArray[0]}"/>
<c:out value="${myArray[1]}"/>

greetz
manuel
Hi,

Please let us know in more depth on what do you want if all above solution do not answer your question. I think that manuel_m solution is good enough.

Regards
Dave
Avatar of corduroy9
corduroy9

ASKER

Manuel's idea is what i'm looking for.  Obviously tho I'm not going to want to have static indexes.  I'm going to want this dynamic

So inside my jsp i'll have a for each loop

and then I would want something like

<c:setArray var="row" index=<%i%> value ="$item"/>

Is that the correct way to have index increment?
also setArray is not recognized... y not
Avatar of TimYates
I don't believe setArray exists in JSTL...  (at least not in 1.1)

http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/index.html

it's not there...