Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSTL iterate over list of objects

I am getting a list 'myList' of objects in jsp. Objects I am getting belongs to e.g 'MyClass'. I want to iterate over this list through JSTL.

JSP code is below :

<c:forEach items="myList" var="element">       <tr>     <td>${element.getStatus()}</td>     <td>${element.getRequestType()}</td>     <td>${element.getRequestedFor()}</td>     <td>${element.getTimeSubmitted()}</td>   </tr> </c:forEach> 

I am getting exception :

 00000024 WebApp  E   [Servlet Error]-[/requestHistory.jsp]: com.ibm.ws.jsp.translator.JspTranslationException: JSPG0227E: Exception caught while translating /requestHistory.jsp:       /requestHistory.jsp(31,6) --> JSPG0122E: Unable to parse EL function ${UserProcessRequests.getStatus()}. 

Taglib I am using are :

 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  <%@ page isELIgnored="false"%> 
like image 799
Muhammad Imran Tariq Avatar asked May 05 '11 05:05

Muhammad Imran Tariq


1 Answers

There is a mistake. See this line <c:forEach items="${myList}" var="element">. ${} around 'myList' was missing.

<c:forEach items="${myList}" var="element">    <tr>     <td>${element.status}</td>     <td>${element.requestType}</td>     <td>${element.requestedFor}</td>     <td>${element.timeSubmitted}</td>   </tr> </c:forEach> 
like image 122
Muhammad Imran Tariq Avatar answered Sep 21 '22 17:09

Muhammad Imran Tariq