• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 845
  • Last Modified:

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?
0
corduroy9
Asked:
corduroy9
1 Solution
 
KuldeepchaturvediCommented:
Well I do not recall any straight way of doing it...

normally I just add all the strings together in one String ( delimited by say ":" and then use c:split() on it
0
 
manuel_mCommented:
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
0
 
suprapto45Commented:
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
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
corduroy9Author Commented:
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?
0
 
corduroy9Author Commented:
also setArray is not recognized... y not
0
 
TimYatesCommented:
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...
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now