You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jitesh Sinha <js...@cisco.com> on 2003/08/04 21:18:41 UTC

Newbie:Using two arrays in a tag

How do you access the elements of an array inside <logic:iterate> tag which
takes the collection as another array . I am sure that the length of the two
arrays are same.
In other word how do you substitute the following Java code in Struts :

String[] anArray = myBean.getAnArray() ;
String[] anotherArray = myBean.getAnotherArray() ;
for(int i = 0 ; i < anArray.length ; i++)
{
out.print(anArray[i]) ;
out.print(anotherArray[i]) ;
}

I want to use only one logic:iterate tag.Is that possible?

Thanks,
Jitesh
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Newbie:Using two arrays in a tag

Posted by Kris Schneider <kr...@dotech.com>.
Are you sure you've got it installed? The following JAR files should appear in
your app's WEB-INF/lib dir:

jaxen-full.jar
jstl.jar
saxpath.jar
standard.jar

and you might not even need jaxen-full.jar and saxpath.jar unless you're doing
XML stuff. If you don't have those JAR files, head to:

http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html

Quoting Jitesh Sinha <js...@cisco.com>:

> But Kris,when I tried to use JSTL for another requirement by using taglib
> uri as
> <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> i get the
> error
> that this taglib
> cannot be located. I am not able to even see the page
> "http://java.sun.com/jstl/core" through browser .Browser shows me 'File not
> found' . What can be the reason????
> 
> -----Original Message-----
> From: Kris Schneider [mailto:kris@dotech.com]
> Sent: Tuesday, August 05, 2003 1:52 AM
> To: Struts Users Mailing List
> Subject: Re: Newbie:Using two arrays in a <logic:iterate> tag
> 
> 
> JSTL is your friend:
> 
> <c:forEach var="item" items="${anArray}" varStatus="i">
>   <c:out value="${item}"/>
>   <c:out value="${anotherArray[i.index]}"/>
> </c:forEach>
> 
> Assuming "anArray" and "anotherArray" are scoped attributes...
> 
> Quoting Jitesh Sinha <js...@cisco.com>:
> 
> > How do you access the elements of an array inside <logic:iterate> tag
> which
> > takes the collection as another array . I am sure that the length of the
> > two
> > arrays are same.
> > In other word how do you substitute the following Java code in Struts :
> >
> > String[] anArray = myBean.getAnArray() ;
> > String[] anotherArray = myBean.getAnotherArray() ;
> > for(int i = 0 ; i < anArray.length ; i++)
> > {
> > out.print(anArray[i]) ;
> > out.print(anotherArray[i]) ;
> > }
> >
> > I want to use only one logic:iterate tag.Is that possible?
> >
> > Thanks,
> > Jitesh
> 
> --
> Kris Schneider <ma...@dotech.com>
> D.O.Tech       <http://www.dotech.com/>

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Newbie:Using two arrays in a tag

Posted by Jitesh Sinha <js...@cisco.com>.
But Kris,when I tried to use JSTL for another requirement by using taglib
uri as
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> i get the error
that this taglib
cannot be located. I am not able to even see the page
"http://java.sun.com/jstl/core" through browser .Browser shows me 'File not
found' . What can be the reason????

-----Original Message-----
From: Kris Schneider [mailto:kris@dotech.com]
Sent: Tuesday, August 05, 2003 1:52 AM
To: Struts Users Mailing List
Subject: Re: Newbie:Using two arrays in a <logic:iterate> tag


JSTL is your friend:

<c:forEach var="item" items="${anArray}" varStatus="i">
  <c:out value="${item}"/>
  <c:out value="${anotherArray[i.index]}"/>
</c:forEach>

Assuming "anArray" and "anotherArray" are scoped attributes...

Quoting Jitesh Sinha <js...@cisco.com>:

> How do you access the elements of an array inside <logic:iterate> tag
which
> takes the collection as another array . I am sure that the length of the
> two
> arrays are same.
> In other word how do you substitute the following Java code in Struts :
>
> String[] anArray = myBean.getAnArray() ;
> String[] anotherArray = myBean.getAnotherArray() ;
> for(int i = 0 ; i < anArray.length ; i++)
> {
> out.print(anArray[i]) ;
> out.print(anotherArray[i]) ;
> }
>
> I want to use only one logic:iterate tag.Is that possible?
>
> Thanks,
> Jitesh

--
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Newbie:Using two arrays in a tag

Posted by Kris Schneider <kr...@dotech.com>.
JSTL is your friend:

<c:forEach var="item" items="${anArray}" varStatus="i">
  <c:out value="${item}"/>
  <c:out value="${anotherArray[i.index]}"/>
</c:forEach>

Assuming "anArray" and "anotherArray" are scoped attributes...

Quoting Jitesh Sinha <js...@cisco.com>:

> How do you access the elements of an array inside <logic:iterate> tag which
> takes the collection as another array . I am sure that the length of the
> two
> arrays are same.
> In other word how do you substitute the following Java code in Struts :
> 
> String[] anArray = myBean.getAnArray() ;
> String[] anotherArray = myBean.getAnotherArray() ;
> for(int i = 0 ; i < anArray.length ; i++)
> {
> out.print(anArray[i]) ;
> out.print(anotherArray[i]) ;
> }
> 
> I want to use only one logic:iterate tag.Is that possible?
> 
> Thanks,
> Jitesh

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org