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

Posted on 2012-08-15
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 20

    Accepted Solution

    LVL 11

    Expert Comment

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

    Expert Comment

    whats the error you are getting? by the look of it, it should work.
    LVL 10

    Expert Comment

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Suggested Solutions

    Title # Comments Views Activity
    maxMirror challenge 10 68
    scoresAverage challenge 8 58
    Fibonacci challenge 11 61
    How Complex Is This Java Course ? 9 51
    After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
    Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
    Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

    760 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

    13 Experts available now in Live!

    Get 1:1 Help Now