Accessing nested objects in JSP View
<p>I have a list of Objects. The object is of the following class:</p>

<pre><code>@Entity
@Table(name="User")
public class User {
    @Id
    @Column(name = "userid" ,unique=true, nullable=false)
    private String id;
    @Column(name="firstname")
    private String firstname;
    @Column(name="lastname")
    private String lastname;
    @Column(name="title")
    private String title;
    @Embedded
    private Address address;
    @ManyToMany
    @JoinTable(name="phone_user", joinColumns={@JoinColumn(name="userid")},
    inverseJoinColumns={@JoinColumn(name="phoneid")})
    private List&lt;Phone&gt; phones;

    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }

    public String getFirstname() {
        return firstname;
    }
    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public String getLastname() {
        return lastname;
    }
    public void setLastname(String lastname) {
        this.lastname = lastname;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }

    public Address getAddress() {
        return address;
    }
    public void setAddress(Address address) {
        this.address = address;
    }

    public List&lt;Phone&gt; getPhones() {
        return phones;
    }
    public void setPhones(List&lt;Phone&gt; phones) {
        this.phones = phones;
    }





}
</code></pre>

<p>In my controller method I add this list to the model as:</p>

<pre><code>model.addAttribute("lists",phone.getUsers());
</code></pre>

<p>In my JSP I am unable to access the lists getter methods. I need to access the getId and the getFirstName getters. 
This is my JSP:</p>

<pre><code>&lt;c:forEach items="${lists}" var="listvalue"&gt;
    &lt;tr&gt;
        &lt;td&gt;Employee ID: &lt;c:out value="${listvalue}"/&gt;&lt;/td&gt;
        &lt;td&gt;Employee Pass: &lt;c:out value="${listvalue.getId()}"/&gt;&lt;/td&gt;  
    &lt;/tr&gt;
&lt;/c:forEach&gt;
</code></pre>

<p>I get the following error:</p>

<pre><code>org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/views/phoneview.jsp at line 33
</code></pre>

<p>line 33 is :</p>

<pre><code>&lt;td&gt;Employee Pass: &lt;c:out value="${listvalue.getId()}"/&gt;&lt;/td&gt;
</code></pre>

<p>I can't seem to figure out what the problem is.</p>