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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Should localization be done inside spring controller 5 37
Configure a Bean in an XML file 4 49
Crystal Reports Licensing Questions 4 65
Java Eclipse Loop 3 31
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

730 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