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

Posted on 2012-08-15
Medium Priority
Last Modified: 2012-08-30
Here is a snippet of my Servlet code:

ArrayList personList = new ArrayList();
Person person1 = new Person();
person1.setAddress("100 Main");

Person person2 = new Person();
person2.setAddress("200 Main");
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:
       <c:forEach var="theperson" items="${persons}">

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.
Question by:gdkinney_2
LVL 21

Accepted Solution

Amitkumar P earned 2000 total points
ID: 38297056
LVL 11

Expert Comment

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

Expert Comment

ID: 38311946
whats the error you are getting? by the look of it, it should work.
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.

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