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

Posted on 2014-01-25
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){

Open in new window

Here is the JSP snippet

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

							<div class="panelContent"></div>

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!
Question by:grnmachine

Accepted Solution

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

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

Open in new window


Author Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now