?
Solved

How to loop through list in jsp using for each and retrieve its properties

Posted on 2014-01-25
2
Medium Priority
?
1,012 Views
Last Modified: 2014-02-04
Hi, I am having trouble understanding how to retrieve properties out of a collection for display in my jsp page.

I am retrieving a list that is Iterable<company> then putting it into a list in my backing bean

here is the code that is in my backing bean to establish the company name

List<Company> companyFullName = Lists.newArrayList();
Iterable<Company>  owner = Lists.newArrayList();

owner = this.groups.owners().activeAsOf(new YearMonth(this.getMonth())).list();

		for(Company company: owner){
			companyFullName.add(company);
			
		}
		
		super.getContext().putIntoRequest("companyFullName",companyFullName);

Open in new window


Here is the JSP snippet

<c:forEach items="${requestScope.companyFullName}" var="currentCompany" varStatus="loop">
<div class="companyAccordion">
<h3>
	${currentCompany.codeName} - ${currentCompany.commonName}
</h3>

						<div>
							<div class="panelContent"></div>
						</div>
					</div>
				</c:forEach>

Open in new window



This of course isn't working, but I'm not sure what exactly I need to do to get these properties out of the list to use in the header.

Could someone please shed some light on this? Thanks!
0
Comment
Question by:grnmachine
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
Mahesh Bhutkar earned 2000 total points
ID: 39814679
Check out this one,

<c:forEach items="${requestScope.companyFullName}" var="currentCompany">
<div class="companyAccordion">
	<h3>
		<c:out value="${currentCompany.codeName}"/> - <c:out value="${currentCompany.commonName}"/>
	</h3>
	<div>
		<div class="panelContent"></div>
	</div>
</div>
</c:forEach>

Open in new window

0
 

Author Comment

by:grnmachine
ID: 39832714
Thank you for your response, thats what I was looking for.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question