?
Solved

Need to display an ArrayList of Java Bean properties in a JSP page using Expression Language (EL)

Posted on 2012-08-15
4
Medium Priority
?
1,894 Views
Last Modified: 2012-08-30
Here is a snippet of my Servlet code:

ArrayList personList = new ArrayList();
Person person1 = new Person();
person1.setName("Fred");
person1.setAddress("100 Main");
person1.setZipCode("90289");
personList.add(person1);

Person person2 = new Person();
person2.setName("Andy");
person2.setAddress("200 Main");
person2.setZipcode("90289");
personList.add(person2 );

request.setAttribute("persons", personList);
request.getRequestDispatcher("jsps/displayResults.jsp").forward(request, response);

________________________________________________________________________________________

In my displayResults.jsp I have the following code snippet:
<table>
       <c:forEach var="theperson" items="${persons}">
             <tr><td>${theperson.name}</td></tr>
             <tr><td>${theperson.address}</td></tr>
             <tr><td>${theperson.zipcode}></td></tr>
       </c:forEach>
</table>


If I use an ArrayList of Strings I can get it to print out the strings in the ArrayList.  But I can't get it to work with an ArrayList of "Person" beans.
0
Comment
Question by:gdkinney_2
4 Comments
 
LVL 21

Accepted Solution

by:
Amitkumar P earned 2000 total points
ID: 38297056
0
 
LVL 11

Expert Comment

by:Manish
ID: 38299245
In scriptlet , are you able to access these object?
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 38311946
whats the error you are getting? by the look of it, it should work.
0
 
LVL 10

Expert Comment

by:Pramod Kumar
ID: 38315670
Could you share your bean source code. Just to ensure that the getters are available there.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
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…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month16 days, 17 hours left to enroll

862 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