Link to home
Start Free TrialLog in
Avatar of grnmachine
grnmachineFlag for Canada

asked on

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

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!
ASKER CERTIFIED SOLUTION
Avatar of Mahesh Bhutkar
Mahesh Bhutkar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of grnmachine

ASKER

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