what is ${status.value} and ${(branch.key)???

i dont know JSTL much;what contents should i set in branches ?what is ${status.value}???


<c:forEach var='branch' items='${branches}'>
                <c:set var="chk" value="false"/>
            <c:forEach var='branch1' varStatus="stat" items='${status.value}'>
                  <c:if test="${(branch.key)==status.value[stat.index]}">       
                      <c:set var="chk" value="checked"/>
                  </c:if>
                </c:forEach>      
      <input type="checkbox" name="${status.expression}"
                              <c:out value="${chk}"/>
                              value="${branch.key}" />${branch.value}
                              <br/>
      </c:forEach>
LVL 20
chaitu chaituAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

objectsCommented:
branches is the name of the collection you want to iterate over in 1st loop
the inner loop will iterate over the value of the value property of the status bean ie. status.getValue()
0
chaitu chaituAuthor Commented:
show me an example so that I will understand better
0
objectsCommented:
branch.key is the is the value of the key property of the current element for the outer loop
ie.  branch.getKey()
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

objectsCommented:
example of what exactly?
0
chaitu chaituAuthor Commented:
branches.add("aaa");
branches.add("bbb");

0
objectsCommented:
jstl is primarily for accessing bean properties, not for making arbitrary method calls.
That should be handled in your controller.
0
ManishLeadCommented:
objects,
   Any good JSTL tutorial or ref?
0
chaitu chaituAuthor Commented:
getting exception in jsp code....

            <c:forEach var='branch' items='${branches}'>
                <c:set var="chk" value="false"/>
            <c:forEach var='branch1' varStatus="stat" items='${status.value}'>
      <c:if test="${(branch.key)==status.value[stat.index]}">       
          <c:set var="chk" value="checked"/>
      </c:if>
          </c:forEach>      
      <input type="checkbox" name="${status.expression}"
                              <c:out value="${chk}"/>
                              <c:out value="${branch.key}" />${branch.value}
                              <br/>
      </c:forEach>

javax.servlet.ServletException: Unable to find a value for "key" in object of class "java.lang.String" using operator "."


controller
*********

      branches.add("1111");
            branches.add("2222");
            branches.add("3333");

String[] user=  (String[])branches.toArray(new String[0]);

        request.setAttribute("branches",branches);
0
objectsCommented:
branches is a list of strings, so branch will be a String

and here:

     <c:if test="${(branch.key)==status.value[stat.index]}">      

you try to access the key property of branch which does not exist
ie. String does not have a method getKey()
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.