loop in struts


Web tier: servlets, JSP, Web frameworks: loop in struts

  1. loop in struts (7 messages)

    I want to write a loop using struts tags to do the following:

    for (int i=0;i<max;i++) {

    where max is a property of a bean named statusbean with session scope.

    can anyone help?

    Threaded Messages (7)

  2. loop in struts[ Go to top ]

    hi nima,

    try to use the logic-taglib coming with struts. Your snipplet would then look like:

    <logic:iterate id="element" name="mycollection">
    Next element is <bean:write name="element" property="value"/>

    As an altenative, take a look at JSTL (http://jakarta.apache.org/taglibs/) with regard to looping capabilities like "<c:forEach>" or something.

    Hope it helps,
  3. loop in struts[ Go to top ]

    hi Kristian,
    tancks for your help.

    but I wanted to know if I could do this without making a new Collection and passing it. cause my needed Collection is only a set of integers. I mean 1 2 3 4 ...

    Do you thinck there is any way to do this?
  4. loop in struts[ Go to top ]


    if you just want to loop over some integers, you can use JSTL. Assuming you have added the JSTL-Lib to you webapp, all you have to do is something like the following in your jsp-Page:

    <%@ taglib uri="/tags/c" prefix="c"%>
    <c:forEach begin="1" end="100" var="cur">
      <c:out value="${cur}"/>

    In you processed HTML-Page, the integers from 1 to 100 will be rendered.

    Hope this helps,
  5. for Loop[ Go to top ]

    Hi I need row wise like..

    In jsp it will display 

     for(int i=0; i<=5 ; ){
             <TR><TD>The cost of $shares share/s is <%=i %> #x0024s</TD>
             <TD>The dividend is <%= i+1 %> #x0024s</TD>
             <TD>The dividend is <%= i+2 %> #x0024s</TD>
             <TD>The dividend is <%= i+3 %> #x0024s</TD></TR> 


    like that jsp i need  struts also 


    <c:forEach var='desig' items='${DESIG_LIST}'>  


     <td height="28" align="center" valign="middle" style="padding-left:15px;"  class="titles">

    <c:out value="${desig.desiName}"></c:out>




    Please help this 

    Thanks in advance




  6. loop in struts[ Go to top ]


    if you want to iterate over a certain amount of iterations, you can use the start and end parameters of the Struts <logic:iterate> tag.

    Please look into the manual first before asking questions!


    René Zanner
  7. loop in struts[ Go to top ]

    Hi Rene,
    tnx for your help, but, unfortunately, there is no start and end parameters acceptable in <logic:iterate> tag.

    I think you should look into the manual before answering the questions.
  8. Sorry![ Go to top ]

    Shame on me - I mixed up the taglibs!

    I did not want to offend you and in future will look into the docs first - sorry for trying to teach you ... :o(

    I found the begin and end parameters in the JSTL <core:forEach> tag.