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!

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.