Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2011
    Posts
    62
    Rep Power
    0

    Default Rewriting EL expressions in a loop

    In my jsp page some data is read from the request object and displayed:
    XML Code:
    Dataset 1: 
    <br></br>
    ${requestScope.DataObj.person[0].name} 
    <br></br>
    ${requestScope.DataObj.person[0].age} 
    <br></br>
    <img src="${requestScope.DataObj.person[0].image}" />
    <br></br>
    
    Dataset 2: 
    <br></br>
    ${requestScope.DataObj.person[1].name} 
    <br></br>
    ${requestScope.DataObj.person[1].age} 
    <br></br>
    <img src="${requestScope.DataObj.person[1].image}" />
    <br></br>
    Is it possible to use a loop here?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: Rewriting EL expressions in a loop

    Look at the standard tag library, specifically the forEach tag.
    That'll iterate over your collection.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Join Date
    Aug 2011
    Posts
    62
    Rep Power
    0

    Default Re: Rewriting EL expressions in a loop

    The problem are the details. I tried it this way, but it doesn't work:
    XML Code:
    <c:forEach var="x" items="${requestScope.DataObj.person}">   
    <c:out value="${x.name}" />
    <br></br>
    </c:forEach>
    When I call this, I don't get any output:
    XML Code:
    <c:choose>
    	<c:when test="${requestScope.DataObj.person}">
                    <c:out value="data available: yes"></c:out>
    	</c:when>
    	<c:otherwise>
    		<c:out value="data available: no"></c:out>
    	</c:otherwise>
    </c:choose>
    Last edited by noodle_variation_187-X; 07-06-2012 at 03:57 PM.

  4. #4
    oszc is offline Member
    Join Date
    Aug 2011
    Posts
    20
    Rep Power
    0

    Default Re: Rewriting EL expressions in a loop

    hey ,
    did you copy the standard tag Jar to your project?
    and <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> in your page?

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: Rewriting EL expressions in a loop

    What does "it doesn't work" mean?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. reading and rewriting ( about String )
    By silvathins in forum Apache POI
    Replies: 1
    Last Post: 05-03-2012, 09:27 AM
  2. rewriting a recursive function
    By Wnt2bsleepin in forum New To Java
    Replies: 6
    Last Post: 04-19-2012, 05:48 PM
  3. Arguments for/against rewriting API classes/methods?
    By Diargg in forum Advanced Java
    Replies: 3
    Last Post: 04-04-2012, 03:18 PM
  4. Replies: 0
    Last Post: 01-13-2011, 10:58 AM
  5. url rewriting
    By jithan in forum Java Servlet
    Replies: 2
    Last Post: 06-23-2008, 06:11 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •