Problem in Iterating using logic:iterate tag

Hi ,
I am using <logic:iterate> tag to iterate through a list of contents.
When the List size is 1222, all the Contents in the List are displaying properly.
When the size execdes 1223, the JSP is not displaying properly.
I am not getting any exception also.
I have added try and catch. Still it is not showing any exception.
When the size is more than 1300, Some contents are not displaying in JSP.
Can any one provide some inputs, so that I can crack my issue.
The JSP code :
          <logic:iterate id="someXXXX" property="someXXX" name="someXXX" indexId="count" scope="request">
          <tr>
<td><html:text name="someXXXX" property="someXXXX"
                         size="50" maxlength="50" onchange="setDirty()" indexed="true"/> </td>               
<td height="15" align="center"><html:checkbox property="someXXXX" name="someXXXX" indexed="true" onclick="setCheckboxFlag(this)" />               
               <td width="4"> </td>               
          </tr>
          <html:hidden property="someXXXX" name="someXXXX" indexed="true" />
          </logic:iterate>
Thanks,
RamaKrishna

get the records and store them in a collection. Store the collection in session. take the first 10 records as a subset and pass it to the iterate tag. use the hidden field to keep the last record number in the jsp. So when you first see the jsp the first 10 records will be shown and when user clicks for next records send the hidden field value to the server and take next 10 records as subset and pass it to iterate tag. This is how you can do this. but if you have thousands of records storing them in the session is not recommended. you can pull them directly from the database.

Similar Messages

  • How to use logic:interate tag in this case? thanks a lot.

    a javabean:
    a{
    int a;
    ArrayList bList (to store some strings);
    request.setAttribute("a",a);
    then how can I use <logic:iterate> tag to loop to use <bean:write> tag to write out the strings contained by bList?

    use getparams and get that attribute(arraylist)
    define a bean in jsp with property as this attribute for which u should have a getter method in context
    the following is to iterate through arralist of arraylist
    <logic:iterate id="accList" name="<%=subAppContextName%>" ="accountsHoldedList">
              <tr>
    <logic:iterate id="accList2" name="accList">
    <td> <bean:write name="accList2"/> </td>
    </logic:iterate>
    <td>
    <jfp:link styleClass="appNavNext" warn="false" bundle="<%=bundleName%>" key="GiveNotice" paramId="selectedAccount" paramName="accList2" href="javascript:submitMyForm();"></jfp:link>
    </td>
    </tr>
    </logic:iterate>
    accountsHoldedList is the one which is set in Context and i am iterating to display it.
    bye

  • Problem in using logic:iterate in struts

    Hello all,
    I have developed 1 application using struts.I am getting this error in my JSP.I have used logic:iterate.I am able to see the list of topics in my JSP but I am getting error when I am clicking on the hyperlink.This is the error.Please help me.Any help will be highly appreciated.Thanx in advance.
    ApplicationDispatcher[TGMC_DB1-2009] PWC1231: Servlet.service() for servlet jsp threw exception
    javax.servlet.jsp.JspException: Cannot find bean: "topic_list" in any scope
    at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:935)
    at org.apache.struts.taglib.logic.IterateTag.doStartTag(IterateTag.java:232)
    at org.apache.jsp.viewThreads_jsp._jspService(viewThreads_jsp.java from :121)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:470)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:364)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
    at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:853)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:542)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:474)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:366)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
    at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
    at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
    at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:318)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:270)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:339)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:261)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:212)
    at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
    at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
    StandardWrapperValve[action]: PWC1406: Servlet.service() for servlet action threw exception
    javax.servlet.jsp.JspException: Cannot find bean: "topic_list" in any scope
    at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:935)
    at org.apache.struts.taglib.logic.IterateTag.doStartTag(IterateTag.java:232)
    at org.apache.jsp.viewThreads_jsp._jspService(viewThreads_jsp.java from :121)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:470)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:364)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
    at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:853)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:542)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:474)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:366)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
    at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
    at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
    at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:318)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:270)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:339)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:261)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:212)
    at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
    *//Action class*
    package com.myapp.struts;
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import java.util.ArrayList;
    public class DiscussionForumViewAction extends Action {
      public ActionForward execute(ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response)
        throws IOException, ServletException
          String target = new String("success");
            try
             ArrayList TopicList = null;
             TopicList= Discussion_Forum.getTopics();
             request.setAttribute("topic_list",TopicList);
            catch(Exception ex)
                System.out.println(ex.getMessage());
          return (mapping.findForward(target));
    *// jsp*
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
        </head>
        <body>
            <html:form action="/view_topic.do">
            <br><br><br>
    <center><h2><u>Discussion Forum</u></h2></center>
    <br><br>
            <div align="center">
                  <html:errors />
                <table border="1" cellspacing="0" cellpadding="0">
                                <thead>
                                 <tr>
                                    <th>Forum</th>
                                    <th>Topic/Messages</th>
                                   <th>Last Post</th>
                                 </tr>
                                </thead>
                                <tbody>
                                    <logic:present name="topic_list" scope="request">
                                      <logic:iterate id="TopicForm" name="topic_list">
                                        <tr align="left">
                                          <td>
                                             *<a href="get_threads.do?topic_id=<bean:write name="TopicForm" property="topic_id"/>"><font color="#336699">     <bean:write name="TopicForm" property="topic_name"/></font></a>*
                                        </td>
                                        <td>
                                        <bean:write name="TopicForm" property="no_of_threads"/>
                                       </td>
                                       <td>
                                       <bean:write name="TopicForm" property="last_post" />
                                      </td>
                                    </tr>
                                </logic:iterate>
                            </logic:present>
                     </tbody>
               </table>
            </div>
        </html:form>
    </body>
    </html>
    *//struts config*
        <action path="/view_topic"
                   type="com.myapp.struts.DiscussionForumViewAction"
                   name="TopicFormBean"
                   scope="session"
                   validate="true"
                   input="/Discussion_forum.jsp">
                   <forward name="success" path="/Discussion_forum.jsp" />
                   <forward name="failure" path="/welcomeStruts.jsp" />
           </action>
    *//formbean*
    package com.myapp.struts;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
    public class TopicFormBean extends ActionForm {
      protected String topic_name;
      protected String description;
      protected Integer no_of_threads;
      protected String last_post;
      protected Integer topic_id;
        public String getTopic_name() {
            return topic_name;
        public void setTopic_name(String topic_name) {
            this.topic_name = topic_name;
        public String getDescription() {
            return description;
        public void setDescription(String desc) {
            this.description = desc;
         public Integer getNo_of_threads() {
            return no_of_threads;
        public void setNo_of_threads(Integer no_of_threads) {
            this.no_of_threads = no_of_threads;
        public String getLast_post() {
            return last_post;
        public void setLast_post(String last_post) {
            this.last_post = last_post;
         public Integer getTopic_id() {
            return topic_id;
        public void setTopic_id(Integer topic_id) {
            this.topic_id = topic_id;
          }

    Thanx Praveen,
    I have already googled this error.I found many people have already posted this problem.But my problem is different.I am getting error only when clicking on hyper link otherwise that arraylist is displaying result on jsp.
    I have also gone through this link
    http://blog.smartlogicsolutions.com/2007/06/12/struts-11-problems-with-logiciterate-tags-and-cannot-find-bean-xxx-under-any-scope/
    It talks about :-
    1) using logic:present tag if your arraylist can be null.
    2) Take care that getter setter are properly written.. I mean there are no spelling mistakes.
    3)arraylist is set in request scope.
    4)I have also included the necessary taglibs.
    I have confirmed all these things.Please help me.I am pretty new to java.Thanx.
    Neha

  • How can I write the analogous code to the logic:iterate tag functionality

    Hai This is Rayalu .And I am very new to the Java World. I have a doubt?.How can I write the analogous code to the<logic:iterate> tag functionality using the JSP Tag Libraries . Pleae Send me some examples .

    Hi,
    SELECT objnr objid aufnr
            from afih
            into table t_afih.
    SELECT objnr
            from JEST
            into table t_JEST
            where stat = 'A0045'
               OR stat = 'A0046'
               AND inact 'X'.
    SELECT objnr
            from COBRB
            into table t_cobrb.
    SELECT arbpl werks objid objty
          from crhd
          INTO table it_crhd
          FOR ALL ENTRIES IN it_afih
          WHERE objty eq 'D'
          AND gewrk = it_afih-objid.
    SELECT aufnr objnr auart txjcd pspel gstrp werks aufnr
            FROM caufv
            INTO table t_caufv
            FOR ALL ENTRIES IN it_afih
            WHERE aufnr = it_afih-aufnr
              And pspel = ' '
              AND txjcd = ' '
             ANd objnr ne it_crhd-objnr
              AND auart in s_wtype
              AND werks in s_plant.
             AND objnr ne it_jest-objnr.
    dont use NE in the select statements, it may effect performance also. Instead use if statements inside
    loops.
    loop at t_caufv.
    read table it_chrd............
      if t_caufv-objnr ne it_chrd-objnr.
      read table it_jest..........
       if   if t_caufv-objnr ne it_jest-objnr.
        (proceed further).
       endif.
      endif.
    endloop.
    hope this helps.
    Reward if useful.
    Regards,
    Anu

  • How to add a row for every 5 records using logic:iterate

    Hi,
    In my application, using logic:iterate iam displaying 20 records per page.
    I want to insert a row for every 5 records.
    Please tell how to insert that row.
    Thanks in advance.
    Mohan

    I think this could work for you
    for (int x=1 ; x<=20 ; x++) {
    addRowWithRecord
    if (x%5==0)
    addEmptyRow
    }

  • Using Strut Logic Iterate tag in JavaScript

    Has anyone tried this or experienced this problem.
    I have JSP pages with JavaScript imbedded. Not my web page but an out of the box portal we bought from a vendor. The JavaScript uses the Logic Iterate Strut tag but gives an error in Nitro:
    "feature is not resolved" on the lines where getLink() and getID() are called. I have put the code in other editors and it does not give me any error. Does any one have a clue to why this error occurs or is this something that NitroX can not handle?
    Thanks,
    Zim 8)
    Some of Code:
    function selectFolder(folderName,doExpandPath)
                        if (typeof(doExpandPath) == 'undefined')
                             doExpandPath = true;
                        var form = document.forms['TreeForm'];
                        // unselect old one
                        var cell = document.getElementById(selectedId);
                        if (null != cell)
                             cell.className = '';
                        // select new one
                        if ('/' == folderName.charAt(folderName.length-1))
                             folderName = folderName.substring(0,folderName.length-1);
                        var targetCellId = 'cellLabel./Documents'+folderName;
                        var isContentFolderBrowser = true;
                        try {
                             var sideBarSelected = top.frames['main'].window.sideBarSelected;
                             isContentFolderBrowser = '/getfolderitems.do' == sideBarSelected;
                             if (!isContentFolderBrowser) {
                             <logic:iterate id="feature" name="userinfobean" property="sideBarFeatures"
                                       type="com.actuate.activeportal.functionality.config.Feature">
                                       if (sideBarSelected == '<%= feature.getLink()%>' )
                                            targetCellId = 'cellLabel./<%= feature.getID()%>';
                                  </logic:iterate>
                        } catch (e) {
                        cell = document.getElementById(targetCellId);

    May I ask why have you done it?
    If it is related to printing of the list then it is of no use.But it IS of use. The objects compEmployees is in scope.
    It has the list we want to print out.
    With logic:iterate:
    <table>
         <tr>
           <th>Number</th>
           <th>Employee</th>
         </tr>
         <logic:iterate name="compEmployees" property="totalEmps" id="emp">
              <tr>
                <td>
                  <bean:write name="emp" property="empNo"/>
                </td>
                <td>
                  <bean:write name="emp" property="empName"/>
                </td>
              </tr>
         </logic:iterate>
    </table>or alternatively with JSTL and c:forEach
    <table>
         <tr>
           <th>Number</th>
           <th>Employee</th>
         </tr>
         <c:forEach items="${compEmployees.totalEmps}" var="emp">
              <tr>
                <td>
                  <c:out value="${emp.empNo}"/>
                </td>
                <td>
                  <c:out value="${emp.empName}"/>
                </td>
              </tr>
         </c:forEach>
    </table>Cheers,
    evnafets

  • C:forEach and logic:iterate tags repeating elements of a collection

    I have an issue that makes absolutely no sense to me. Basically I am using struts, and I am returning a form that contains a List of customers. I am simply trying to iterate that list into a simple table for each customer. The end result will have rows for each table, but I tried to simplify this example.
    The only filter is that I don't want to display customers that don't contain any data that I care to display. In my dataset, there is only one customer that has any data that I care about, and that has been verified in the database and in the backend action feeding the struts page.
    I first attempted this with the c:forEach JSTL tag. What I saw was that the customers were just getting repeated. Instead of showing one table for each customer, it was repeating the tables for each customer equal to the size of the Collection. For example, there were *5* customers in the List, only customer C should have been set into a table, but the table for customer C was being repeated *5* times. I went into the backend code, and made sure the object being sent back to struts contained the correct number of records.
    I then tried the same thing using the logic:iterate Struts EL tag. This did exactly the same thing. Instead of one table for customer C, I had 5 tables, all for customer C.
    Frustrated, I then went back to just writing a basic scriptlet in the JSP, to iterate over the object returned from the struts action. When I did this, everything came back as normal. Only customer C met my conditional statement, and only customer C had a table created in the generated HTML.
    Now I must be missing something with how the JSTL tags are handling the iteration, so I wanted to post the code to see if anyone had any idea what I am doing wrong here.
    The JSP page is found below. As you can see, the first part is done as a scriptlet, and the last part is done with JSTL tags. Unless I am mistaken, the 2 approaches should produce the same result. Please let me know if I am missing something here.
    <%@ include file="/common/customConfig.inc"%>
    <%@ page import="java.util.Iterator,
        com.pw.cemp.webapp.common.forms.CempDocumentsForm,
        com.pw.cemp.webapp.common.views.CustomerView"%>
    Write table with straight scriptlets...
    <br />
    <br />
    <%
        CempDocumentsForm cdForm =
            (CempDocumentsForm) session.getAttribute("cempDocsForm");
        Iterator itCustomers = cdForm.getCustomers().iterator();
        while (itCustomers.hasNext())
            int idx = 0;
            CustomerView customer = (CustomerView) itCustomers.next();
            if (customer.getCemps() != null && !customer.getCemps().isEmpty())
    %>
            <table>
                <% if (idx == 0) { %>
                    <caption>
                        Customer CEMP Listing
                    </caption>               
                <% } %>
                <tbody>
                    <tr>
                        <td class="level1">
                            <%=customer.getName() %> -
                            <%=customer.getSapCustomerId() %>
                        </td>
                    </tr>
                </tbody>
            </table>
    <%      
            idx ++;
    %>
    <br />
    <br />
    Now try using JSTL...
    <br />
    <br />
        <logic:iterate name="cempDocsForm" property="customers" id="customer" indexId="index">
        <!-- <c:forEach items="${cempDocsForm.customers}" var="customer" varStatus="status"> -->
            <c:if test="${not empty customer.cemps}">           
            <table>
                <c:if test="${index == 0}">
                    <caption>
                        Customer CEMP Listing
                    </caption>
                </c:if>
                <tbody>
                    <tr>
                        <td class="level1">
                            <c:out value="${customer.name}" /> -
                            <c:out value="${customer.sapCustomerId}" />
                        </td>
                    </tr>
                </tbody>
            </table>
            </c:if>
        <!-- </c:forEach> -->
        </logic:iterate>
        <br />
        <br />The code above produced the following HTML. As you can see, the scriptlet did exactly what I wanted, it produced 1 table for the only company that met the conditional statement. The JSTL section repeated the table for that one company, equal to the number of items in my List.
    Write table with straight scriptlets...
    <br />
    <br />
            <table>
                    <caption>
                        Customer CEMP Listing
                    </caption>                           
                <tbody>
                    <tr>
                        <td class="level1">
                            FMP Test Company -
                            5
                        </td>
                    </tr>
                </tbody>
            </table>
    <br />
    <br />
    Now try using JSTL...
    <br />
    <br />
            <table>           
                    <caption>
                        Customer CEMP Listing
                    </caption>           
                <tbody>
                    <tr>
                        <td class="level1">
                            FMP Test Company -
                            5
                        </td>
                    </tr>
                </tbody>       
            </table>
            <table>
                <tbody>
                    <tr>
                        <td class="level1">
                            FMP Test Company -
                            5
                        </td>
                    </tr>
                </tbody>
            </table>
            <table>           
                <tbody>
                    <tr>
                        <td class="level1">
                            FMP Test Company -
                            5
                        </td>
                    </tr>
                </tbody>
            </table>
            <table>           
                <tbody>
                    <tr>
                        <td class="level1">
                            FMP Test Company -
                            5
                        </td>
                    </tr>
                </tbody>
            </table>
            <table>       
                <tbody>
                    <tr>
                        <td class="level1">
                            FMP Test Company -
                            5
                        </td>
                    </tr>
                </tbody>
            </table>
        <br />
        <br />Thanks in advance...
    Edited by: cdbyrd on Feb 28, 2008 4:22 PM
    Edited by: cdbyrd on Feb 28, 2008 5:12 PM

    Okay, it looks like I kept moving things around until I stumbled upon something. One thing to note is that I am using Tiles in my struts 1.2.9 application. I don't know if that has anything to do with it, but this is what I found.
    If you notice in my code, with the iteration tags, I had one active and one commented version of the tag. I kept flipping them around, thinking it was some kind of syntax problem or it was specific to either the logic:iterate or c:forEach tag.
    Well, as it turns out, when you comment something the way I did, I think the custom tag processor doesn't ignore the commented sections. I had things commented like the following.
        <logic:iterate name="cempDocsForm" property="customers" id="customer" indexId="index">
        <!-- <c:forEach items="${cempDocsForm.customers}" var="customer" varStatus="status"> -->Now I have done this many times in the past, and I have never noticed any adverse behavior. I guess it was just the correct situation here to make the problem come to the surface. As soon as I removed any comments on the JSP, the page started working as expected. I can't explain why it happens, I just know it happened.
    Does anyone out there have a good explanation for this, so I can put a reason to why I lost so much hair today? Also, does anyone have the proper way to comment out JSTL tags to keep them from being parsed?
    Thanks...

  • How to use logic:present tag in struts el tag

    Hi
    I am trying to use struts el tags in the jsp page.I am struggling with the following exception: Cannot find bean: "result" in any scope.I couldn't understand why this error is coming even i had the property "result" in my ActionForm.
    ActionForm:
    package com.finocus.cam.struts.bean;
    import java.util.List;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.ActionError;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionMapping;
    import com.finocus.cam.common.ValidateFormat;
    public class DetailsForm extends org.apache.struts.action.ActionForm {
         private final static String LOG_TAG = DetailsForm.class.getName() + ".";
         private static final long serialVersionUID = 1L;
         // VARIABLES DECLARATION
         private String name = null;
         private String searchField = null;
         private String searchCriteria = null;
         private String phonenumber = "";
         private String email = "";
         private List results = null;
         private String adminUserName = "";
         private String adminUserEmail = "";
         public DetailsForm() {
         // GETTER AND SETTER METHODS
         public String getName() {
              return name;
         public void setName(String name) {
              this.name = name;
         public String getSearchCriteria() {
              return searchCriteria;
         public void setSearchCriteria(String searchCriteria) {
              this.searchCriteria = searchCriteria;
         public String getSearchField() {
              return searchField;
         public void setSearchField(String searchField) {
              this.searchField = searchField;
         public String getEmail() {
              return email;
         public void setEmail(String email) {
              this.email = email;
         public List getResults() {
              return results;
         public void setResults(List results) {
              this.results = results;
         public String getPhonenumber() {
              return phonenumber;
         public void setPhonenumber(String phonenumber) {
              this.phonenumber = phonenumber;
         public String getAdminUserEmail() {
              return adminUserEmail;
         public void setAdminUserEmail(String adminUserEmail) {
              this.adminUserEmail = adminUserEmail;
         public String getAdminUserName() {
              return adminUserName;
         public void setAdminUserName(String adminUserName) {
              this.adminUserName = adminUserName;
         // DUMPING THE VALUES IN THE CONSOLE
         public void dumpValues() {
              StringBuffer sb = new StringBuffer();
              sb.append("Name'");
              sb.append(name);
              sb.append("SearchField");
              sb.append(searchField);
              sb.append("searchCriteria");
              sb.append(searchCriteria);
              sb.append("'");
              sb.append(" ");
              System.out.println(sb.toString());
         // RESET() METHOD IS USED FOR STORE FORM'S CURRENT VARIABLES DECLARATION
         public void reset(ActionMapping actionMapping, HttpServletRequest request) {
              System.out.println("reset() method is called");
              this.email = null;
              this.searchCriteria = null;
              this.searchField = null;
              this.results = null;
         // VALIDATE() METHOD IS USED TO VALIDATE THE FORM DATA
         public ActionErrors validate(ActionMapping actionMapping,
                   HttpServletRequest request) {
              ActionErrors errors = new ActionErrors();
              System.out.println("Validate()is called");
              // Determine if name has been entered.
              if (getName() == null || getName().length() == 0
                        || getName().equals(" ")) {
                   errors.add("accountText", new ActionError("searchText.error"));
              } else if ((getSearchField().equals("name") == true)
                        && (ValidateFormat.isValidText(getName()) == false)) {
                   errors.add("validAccountName", new ActionError("validName.error"));
              if (getSearchField() == null || getSearchField().length() == 0) {
                   errors.add("accountSearchField", new ActionError(
                             "searchField.error"));
              } else if ((getSearchField().equals("email") == true)
                        && (ValidateFormat.isValidEmail(getName()) == false)) {
                   errors
                             .add("validAccountEmail", new ActionError(
                                       "validEmail.error"));
              } else if ((getSearchField().equals("phonenumber") == true)
                        && (ValidateFormat.isValidPhoneNoFormat(getName()) == false)) {
                   errors.add("validPhoneFormat", new ActionError(
                             "validPhoneFormat.error"));
              if ((getSearchField().equals("searchallfields"))
                        && ((ValidateFormat.isValidText(getName()) == false)
                                  && (ValidateFormat.isValidEmail(getName()) == false) && (ValidateFormat
                                  .isValidPhoneNoFormat(getName()) == false))) {
                   errors.add("validNameEmail",
                             new ActionError("validNameEmail.error"));
              return errors;
    Action class:
    package com.finocus.cam.struts.action;
    import java.util.ArrayList;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import com.finocus.cam.db.CAMDbAccess;
    import com.finocus.cam.struts.bean.DetailsForm;
    public class DetailsAction extends org.apache.struts.action.Action implements
              com.finocus.cam.common.CAMConstants {
         private final static String LOG_TAG = DetailsAction.class.getName() + ".";
         // Global Forwards
         public static final String GLOBAL_FORWARD_search = "login";
         // Local Forwards
         public static final String SUCCESS_search = "success";
         private boolean dumpRequestParams = true;
         public DetailsAction() {
         public ActionForward execute(ActionMapping mapping, ActionForm form,
                   HttpServletRequest request, HttpServletResponse response)
                   throws Exception {
              System.out.println("SearchAccount execute() is called");
              HttpSession session = request.getSession(true);
              ArrayList results = null;
              DetailsForm search = (DetailsForm) form;
              String name = search.getName();
              String searchField = search.getSearchField();
              String searchCriteria = search.getSearchCriteria();
              // Dumping the values of input patameters
              if (dumpRequestParams == true) {
                   request.setAttribute("SearchCriteria", searchCriteria);
                   request.setAttribute("SearchField", searchField);
                   request.setAttribute("Text", name);
                   search.dumpValues();
              // Perform search based on what criteria and search Field was entered.
              CAMDbAccess dbAccess = CAMDbAccess.getInstance();
              if (null != searchCriteria && searchField != null) {
                   System.out.println("Search Criteria =" + searchCriteria
                             + "Selected Option =" + searchField);
                   if (searchCriteria.equals(Search_Account) && searchField != null) {
                        results = dbAccess.searchByAccountInfo(name, searchCriteria,
                                  searchField);
                        System.out.println(" Search criteria :Exact Match was selected.<BR>");
              // Place search results in SearchForm for access by JSP.
              search.setResults(results);
              // Forward control to this Action's input page.
              return mapping.findForward(SUCCESS_search);
    My jsp page:
    <%@ taglib uri="/WEB-INF/tld/struts-bean" prefix="bean" %>
    <%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic-el" %>
    <%@ taglib uri="/WEB-INF/tld/struts-html" prefix="html" %>
    <html:html>
    <head>
    <title>Search Page</title>
    </head>
    <body colorants="LightGreen">
         <table width="100%" bgcolor="LightGreen">
              <tr>
                   <td align="left"><font color="brown"><h3><b>Search Info</b></h3></font><hr></td>
              </tr>
                   <tr>
              <td align="left"><h4><font color="brown"><b>Search Text:</b></font><%=request.getAttribute("Text")%></h4></td>
                   </tr><tr>
              <td align="left"><h4><font color="brown"><b>Search Field:</b></font><%=request.getAttribute("SearchField")%></h4></td>
              </tr><tr>
                   <td align="left"><h4><font color="brown"><b>Search Criteria:</b></font><%=request.getAttribute("SearchCriteria")%></h4></td>
                   </tr><tr>
                   <html:form action="/results.do">
                        <td><center><html:submit value="AllSearchOptions " /></center></td>
                        </html:form>
                   </tr>
              <tr>
                   <td align="left"><font color="brown"><hr><h2><b>Search Results</b></h2></font></td>
              </tr>
              <tr>
              <td>
              <table border="1" cellspacing="1" cellpadding="3" width="70%"
                   bgcolor="white">
                   <logic:present name="searchbyaccount" property="results">
                   Results exists
                        <c:if test="${size==0 }">
                   <center><font color="red"><b>No Results Found</b></font></center>
                   </c:if>
                   <br>
                        <c:if test="${size>0}">
                        Size is greater than ZERO
                             <table border="1" cellspacing="1" cellpadding="3" width="70%"
                                  bgcolor="white">
                                  <tr>
                                      <th>Customerid</th>
                                       <th>First Name</th>
                                       <th>Last Name</th>
                                       <th>Email</th>
                                       <th>phone Number</th>
                                       <th>Details</th>
                                  </tr>
                                       <c:forEach var="result" items="${results}">
                                        <c:out value="${result}"/>
                                       <tr>
                                            <td><bean:write name="result" property="customerid"></bean:write></td>
                                            <td><bean:write name="result"
                                                 property="accountAdminFirstName"></bean:write></td>
                                            <td><bean:write name="result"
                                                 property="accountAdminLastName" /></td>
                                            <td><bean:write name="result" property="accountability" /></td>
                                            <td><bean:write name="result" property="accountAdminPhone" /></td>
                                            <td><html:form action="/accountDetails.do">
                                                      <html:submit value="Details" />
                                            </html:form></td>
                                       </tr>
                                  </c:forEach>
                             </table>
                        </c:if>
              </logic:present>
              </table>
              </td>
              </tr>
         </table>
    </body>
    </html:html> Please refer me where i done a mistake.Thanks in Advance

    hi all,
    I am doing programs in sturts. My program
    My program purpose is to retrieve data from the
    database.My database is MySql. I know that we can
    write connection code in Action Class, it is ok for
    some less prog's if i want to use the sane connection
    code in more Action Classes it is vasting time and
    so.I don't think it's a good idea to put database code in Action classes. (That's one of the biggest drawbacks of Struts - it's completely tied to Actions, HTTP, and the Web.) Better to move that code into plain old Java objects and let the Actions call them.
    You'll be able to test them without the container or Struts, and you'll be able to reuse those objects in other, non-Web contexts.
    So i want to use <data-sources> tag that is available
    in struts-config.xml. I know that thre is tag withThis is the wrong place to configure a connection pool, too. Struts should have nothing to do with it. What if you change Web frameworks to WebWork or Spring? The connection pool should be configured in the container that hosts your app, not Struts.
    this name, but the problem is i don't know how to use
    this tag. If any budy know how to use this please
    tell me the syntax or any example.
    plese... reply soon..Don't do it. Think about doing it in your container, not Struts.
    %

  • Pls help me writing logic:iterate tag in jsp page

    Hey guys , I am struck in retriving string p1,p2,p3 in the jsp page
    Pls have a look ata the code
    In DAO class:-
    StdprdDAO.java
    Public arrayList getPFP()
    ArrayList a = new ArrayList();
    While(rs.next())
         columnsVO colVO = new columnsVO;
         colVO.setProduct(rset.getString(1));//will store in String colProduct
         colVO.setFamily(rset.getString(2));//will store in String colFamily
    colVO.setPrice(rset.getString(3));//will store in String colPrice
    a.add(colVO);
    return a;
    In Action Class:-
    ArrayList final = null;
    StdprdDAO DAO = new stdprdDAO();
    final = DAO.getPFP();
    For(int i = 0; final !=null && i<final.size() ; i++)
         columnsVO VO = null;
         VO = (columnsVO)final.get(i);
         String p1 = (String) VO.getProduct();
         String p2 = (String) VO.getFamily();
         String p3 = (String) VO.getPrice();
         Request.setAttribute(“p1”,p1);
         Request.setAttribute(“p2”,p2);
         Request.setAttribute(“p3”,p3);
    In JSP PAGE:-
    id = “columnsVO”>
    <bean:write name = “columnsVO” property=”final” id=”p1”>
    but still I am doubting my above sentences in jsp page ,so pls correct them if possible.
    Instead of l;ogic:iterate can I use directly getattribute(“p1”)? <logic:iterate
    Still I m doubting I can not utilize columnsVO file in logic:iterate, I can utilize only formbean file.
    So pls help me with this.

    May I ask why have you done it?
    If it is related to printing of the list then it is of no use.But it IS of use. The objects compEmployees is in scope.
    It has the list we want to print out.
    With logic:iterate:
    <table>
         <tr>
           <th>Number</th>
           <th>Employee</th>
         </tr>
         <logic:iterate name="compEmployees" property="totalEmps" id="emp">
              <tr>
                <td>
                  <bean:write name="emp" property="empNo"/>
                </td>
                <td>
                  <bean:write name="emp" property="empName"/>
                </td>
              </tr>
         </logic:iterate>
    </table>or alternatively with JSTL and c:forEach
    <table>
         <tr>
           <th>Number</th>
           <th>Employee</th>
         </tr>
         <c:forEach items="${compEmployees.totalEmps}" var="emp">
              <tr>
                <td>
                  <c:out value="${emp.empNo}"/>
                </td>
                <td>
                  <c:out value="${emp.empName}"/>
                </td>
              </tr>
         </c:forEach>
    </table>Cheers,
    evnafets

  • Using Logic iterate to display a arraylist in STRUts

    I m having a form bean containg a string array......
    <form-bean
    name="myDynaForm"
    type="org.apache.struts.validator.DynaValidatorForm">
    <form-property name="names" type="java.lang.String[]" />
    </form- bean>
    and in my jsp , i m using .......
    <logic:iterate name="myDynaForm" property="names" id="names" >
    <tr>
    <td class="style3" align="left" width="30%" >
    <html:textarea property="names" cols="40" rows="2" size="40" indexed="true" readonly="true" />
    </td>
    </tr>
    Now this code is printing only the first element of String names.
    How can i print all the elemts of answer in my jsp

    How could you do the same thing but using only two cells?
    where the check box returns a specific value in the second.
    in this instance its for a staff registration sheet where a checkbox in (A) would return a set value in (B)
    i know this might sound simple to you guys in the know but i cant figure it out! I have been messing around trying things with the if function but still only shows me the red triangle (syntax error).
    A simple solution would be much appreciated.

  • Not able to use collection multiple times in a jsp using logic:iterate

    I have following question:
    I am working on a report using J2EE. I have a collection(resultset) which has 3 different types of vendors information along with other information in the collection and I want to put them into 3 different sections on my report depend on vendor type in the collection (resultset).
    Anyone know that I can able to use same collection multiple times uisng <logic:iterate> or is any other way of doing this.
    Thanks,

    Enable the logs on your router. Then try to do remote desktop. It will fail of course. After it does, view the logs, there might be ports listed in the incoming logs that you failed to forward.

  • How to select a drop down option item while using logic:iterate?

    I am using the following peice of code -
    {color:#808080}+String countrySelected = (String)request.getAttribute("country");+
    +....+
    +<logic:iterate id="countryVO" name="countryList" type="com.sa.biz.vo.airport.CountryVO">+
    +<%+
    +if (countrySelected != null){+
    String countrySel = countryVO.getCountryCode().toString();
    String selected = (countrySel.equalsIgnoreCase(countrySelected)) ? " " "Selected" : " ";+
    +%>+
    +<option value="<%=countryVO.getCountryCode()%>*<%=selected%>*"><bean:write property="countryName" name="countryVO"/></option>+
    +<%+
    +}+
    +%>+{color}
    {color:#808080}+</logic:iterate>+
    {color}{color:#000000}The drop down is a list of country names (value - country code, display text - country name) which gets populated from the database. I need to ensure that the countrySelected is the menu item which gets selected in the drop down.
    The expected option item is not rendered as selected when i run this code? Please help!!{color}

    <option value="<%=countryVO.getCountryCode()%>" <%=selected%>>Apply the above change which should help you out on the same. :)
    REGARDS,
    RaHuL

  • I am not able to use logic iterate to print values in tables

    hi ,
    Any one plz help me in this..
    i am using struts 1.2.i have values to be displayed in table in an
    ArrayList.for example emp_id one ArrayList.
    emp_name another ArrayList.i want to display this in a jsp page.
    i have these values in ActionForm getter setter method as
    public void setname(ArrayList<String> a1){ 
        this.a1=a1;
      public ArrayList<String> getname(){
        return this.a1;
    public void setname(ArrayList<String> a2){ 
        this.a2=a2;
      public ArrayList<String> getname(){
        return this.a2;
      }to be displayed in jsp page
    as
    emp_ id emp_name
    1 san
    2 jay
    etc
    plzzz hepl me.thanks in advance.........

    Opps,Was too late to reply... :(
    sanjay_gates wrote:
    hi ,
    Any one plz help me in this..
    i am using struts 1.2.i have values to be displayed in table in an
    ArrayList.for example emp_id one ArrayList.
    emp_name another ArrayList.i want to display this in a jsp page.
    i have these values in ActionForm getter setter method as
    public void setname(ArrayList<String> a1){ 
    this.a1=a1;
    public ArrayList<String> getname(){
    return this.a1;
    public void setname(ArrayList<String> a2){ 
    this.a2=a2;
    public ArrayList<String> getname(){
    return this.a2;
    }to be displayed in jsp page
    as
    emp_ id emp_name
    1 san
    2 jay
    etc
    plzzz hepl me.thanks in advance.........Well first thing is that you need to right Convensions.
    public void setName(ArrayList<String> a1){ 
         this.a1=a1;
       public ArrayList<String> getName(){
         return this.a1;
       } and try to iterate it in the below fashoin.
    <logic:iterate id="varString"  name="formBean" property="name">
        <bean:write property="name"/><br/>
    </logic:iterate>Hope this might help :)
    REGARDS,
    RaHuL

  • JSP Compile Error when using dynamic ID in logic:iterate and bean:size

    Hello,
    I try to create a dynamic table with logic:iterate and bean:size tag. Dynamic means the attributes are written by scriptlet. Eg.:
    <logic:iterate id="customerBean" name="<%= formName %>"  property="<%= propertyName%>" length="<%= sRowSize%>">When I replace the id Attribute with propertyName I get compile errors, such as
    the compiler doesn't know the value at runtime:
    Unable to compile class for JSP An error occurred at line: 179 in the jsp file: /pages/formContent.jsp Generated servlet error: _newCustomer.java:1046: Missing term. java.lang.Object <%= propertyName %> = null; ^
    Whats wrong ?
    Thanks for your help

    Solution: don't use a runtime expression for the id attribute.
    The id attribute is used to declare
    - an attribute in scope
    - a scriptlet variable on the page
    These are only available for the duration of the <logic:iterate> tag
    The "id" is only used in your programming. You don't need to make it dynamic.

  • Proble with Struts Taglib "logic:iterate"

    I m designing an simple application, it uses to input some data and then display them.
    For example,I want to input studentID,studentName into the database,but i want to input more than one student data each time.
    This is my FormBean souce:
    package system.form;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionMessage;
    import javax.servlet.http.HttpServletRequest;
    public class StudentForm {
        private String[] studentID;
        private String[] studentName;
        public String[] getStudentID() {
             return studentID;
        public String[] getStudentName() {
             return studentName;
        public void set(String[] field) {
             studentID = field;
        public void set(String[] field) {
             studentName = field;
    }This is my form:
    <html:form method="post" action="/add">
        StudentID: <html:text property="studentID"/>
        StudentName:<html:text property="studentName"/>
        <br/>
        StudentID: <html:text property="studentID"/>
        StudentName:<html:text property="studentName"/>
        <br/>
        <html:submit value="add"/>
    </html:form>The problem is: my StudentForm is in SESSION scope.So after i have input some data,i return to the input page, the text filed will display the data i inputed last time.
    But when i do it, i saw the data in the field are like this:
    [Ljava.lang.String;@595420
    [Ljava.lang.String;@a218a5
    [Ljava.lang.String;@2f54
    Not the data i input,I think the problem is that my attribute in the StudentForm is array string, not string. So there is any problem when display.
    What can i do to resolve it?
    Also,there is another problem.
    In my input page. I must iterate the input field like:
    StudentID: <html:text property="studentID"/>
        StudentName:<html:text property="studentName"/>
        <br/>
        StudentID: <html:text property="studentID"/>
        StudentName:<html:text property="studentName"/>
        <br/>
        ....So when i want to input 10 records each time, i must iterate the html above 10 times,and then 20 records needs iterating 20 times, it's bald and it makes the page hard to read and maintain.
    So i want to use Struts's Tag <logic:iterate> to manipulate it.
    But i don't know how to use it.
    Can anybody give me a hand? Thank u.

    First of all, the studentID and the studentName are related. If you keep them as two separate String arrays, it will be very hard to use logic:iterate to display them together.
    I would suggest that you first create a VO class which contains only studentID and studentName and have getter-setter methods for them. (This is logically good as you are modelling a student using a separate class) And, in your form, declare a studentVO[ ] and have getter-setter methods. You may need to change them and add new ones as they will have to be indexed. This can be looked up in the Struts documentation page.
    Finally in your jsp, iterate over the studentVO[ ] bean and give the respective getter property of studentID and studentName in VO with indexed = "true"....
    <logic:iterate id = "studentVO" name = "<formbean name>" property = "studentVO">
    <html:text name="studentVO" property = "studentID" indexed = "true"/>
    <html:text name="studentVO" property = "studentName" indexed = "true"/>
    etc..
    </logic:iterate>
    (Note that you may have to give the type attribute in your logic:iterate so that it may be cast into the right VO object)
    Hope this helps.

Maybe you are looking for

  • JAVA & XML SCHEMA

    Hi gusy, I'm trying to create a simple schema and I use the fellow namespace in my schema header: <schema xmlns="http://www.w3.org/2001/XMLSchema">The problem consist when I use the Sun One Studio to validate my schema I get the error: General Schema

  • IOS 8.02 Safari for iPhone 5 - A Problem Repeatedly Occurred

    I can't open the webpage: "www.BirthdayExpress.com" (and some others) on my iPhone 5 in Safari since the iOS 8 update.  It would load fine earlier before the update, and also loads on Chrome just fine. The error is: A Problem Repeatedly Occurred on:

  • Restoring iTunes Backup onto my iPad

    Hi, I recently updated my iPad from 4.0.1 to the new iOS 7.0.4. I had made a backup and transferred the apps to my iTunes library. After updating it, I selected the 'Restore from iTunes Backup'. It did restore but it left me on that page. Am I suppos

  • Difference between content pane and jpanel?

    can anyone please tell me the difference between a contentPane and a JPanel?

  • Where did my STB IP address go? Part 2

    I have read the original post about the STB now having an IP but my situation is slightly different. Both of my STBs lose their IP addresses on a daily basis. The solution I've had so far is to reset the modem and reboot the STBs. Problem is I should