Srikanth Sridhar
Srikanth Sridhar

Reputation: 2467

How to iterate an object array set in session scope using JSTL?

I have Manager bean which has array of associatedEmp. I am setting Manager bean to session by using <c:set var="managerBean" value="${managerBean}" scope="session" />. Now in another jsp i am trying to iterate the Employee array by taking the manager bean from session.

  <c:if test="${fn:length(sessionScope.managerBean.associatedEmp) gt 0" >
                    <c:forEach begin="0" end="${fn:length(sessionScope.managerBean.associatedEmp) - 1}" step="1"
                        varStatus="loopCounter"
                        items="${sessionScope.managerBean.associatedEmp}"
                        var="associatedEmployee">
<c:out value="${associatedEmployee.empId}" />

When i try this i am getting "${fn:length(sessionScope.managerBean.associatedEmp) gt 0" contains invalid expression(s): javax.el.ELException" .

I am not able to figure out what is wrong with the length function. Is this the right way to do ? Please help.

Thanks, Sreekanth

Upvotes: 0

Views: 1239

Answers (1)

Alex
Alex

Reputation: 11579

${fn:length(sessionScope.managerBean.associatedEmp) gt 0}

Closing bracket is missing.

Upvotes: 1

Related Questions