Search code examples
jspjsp-tags

JSP, <c:forEach> closes itself to early


I have jsp page given that is being forwarded a ArrayList were Arrangor is bean like class I made with a constructor and getMethods. But when I try to output them In the jsp page. But firebug finds Instances all of the data being sent. But the <:c forEach> tag seems to be closing itself directly around it. Does anyone have any idea why.

edit: Sorry about the bad sentences. edit2 seems a seems the middle sentence got removed

<table border="1">
 <c:forEach items="${arrangorer}" var="arr">
 <tr>
   <th>Id</th>
   <th>Namn</th>
   <th>Telefon Nummer</th>
   <th>Email</th>
 </tr>




<tr>
 <td> <c:out value="${arr.id}"></td>
 <td> <c:out value="${arr.name}"></td>
 <td> ${arr.getNumber()}</td>
 <td> ${arr.getEmail()} </td>
</tr>
</c:forEach>

</table>

Then I include the abouve jsp fragment in at my index page.

<%@page language="java" contentType="text/html"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page import="java.util.ArrayList" %>


  <div id="include_show">
        <jsp:include page="WEB-INF/show.jsp" />
  </div>

I get the following firebug output:

<div id="include_show">
  <c:foreach var="arr" items="[src.arrangor.Arrangor@185cfd8,[email protected]@239d58, src.arrangor.Arrangor@2f32d8, src.arrangor.Arrangor@b327ee, src.arrangor.Arrangor@283d9, src.arrangor.Arrangor@11e342e, src.arrangor.Arrangor@1f3f414, src.arrangor.Arrangor@11d5641]"> 
 </c:foreach>
 <table border="1">
 <tbody>
 <tr>
 <th>Id</th>
 <th>Namn</th> 
 <th>Telefon Nummer</th>
 <th>Email</th>
</tr>
<tr>
  <td><c:out value=""></c:out></td>
  <td><c:out value=""> </c:out></td>
  <td> </td>
  <td> </td>
 </tr>
</tbody>


Solution

  • The taglib declaratiion must be at the top of every JSP using the taglib. So it must also be present at the top of show.jsp.

    Note that there are other errors in your page: unclosed <c:out> tags for example.