0

I am parsing a file and populating a static array of objets in a servlet. Then i pass the static array and try to access the array in the jsp by using the JSTL <c:forEach> tag
in the loop i want to populate a table. I am perfectly able to access the array when I forward a request to another servlet

The structure of the class of objects is as shown here

public class servObjects
    {
        public String hostId;
        public String serverName;

        public servObjects(String string, String string0) {
            hostId=new String(string);
            serverName=new String(string0);
        }
    }

The servlet passes the array in a manner as shown below:

public static servObjects ServArr[];
   ServArr=new servObjects[serverlinescount];
  for(int j=0;j<serverlinescount;j++)
            {
              ServArr[j]=new servObjects(serverNamesArr[j],hostIdArr[j]);
               
             //out.println("SERVER:    "+ServArr[j].serverName+"     "+ServArr[j].hostId+"<br>");
            }
 request.setAttribute("sna", LicenseFileParser.ServArr);
RequestDispatcher rd=getServletContext().getRequestDispatcher("/UpdateLicense.jsp");
          rd.forward(request, response);

This is what i do in the JSP page

<TABLE id="ServerTable" width="350px" border="1">
        <tr>
            <th>select</th>
            <th>serial number</th>
            <th>host Id</th>
           <th>server name</th>
        </tr>
       <c:forEach var="items1" begin="0" items="${requestScope.sna}">
        <TR>
            <TD><INPUT type="checkbox" name="chk[]"/></TD>
            <TD> 1 </TD>
            <TD> <INPUT type="text" name="hostids[]" value="${items1.hostId}"/> </TD>
            <TD> <INPUT type="text" name="servernames[]" value="${items1.serverName}" /> </TD>
        </TR>
        </c:forEach>
       
      
        
        
    </TABLE>

Can anyone tell me where am i going wrong, and what may be other issues if this is correct? A sincere thanks to everyone who helps, in advance!

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by ejosiah
0

You haven't actually told us if there is anything wrong with your program. I've you tested it and is it working as expected?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.