JSTL: Accessing an encapsulated object array

I have a array object encapsulated within another object

1) Class Parent {
   
  private Album album = new Album[2];

}

2) Class Album {

   private String name;

   public String getName()
      return this.name

   public void setName(String name)
      this.name= name

}

3) Inside Java Exe..
Parent parent = new Parent();
request.setAttribute("parent ", parent );

4) JSP
<c:forEach var="image" items="${parent.album}" varStatus="itemStatus" begin="0" step="1">
    <c:out value="${itemStatus.count}" />
    ${image.name}
</c:forEach>


This does not work..it has a problem accesing the object array


5) It works if I save the object in the Request as an array:

Inside Java Exe..
Parent parent = new Parent();
request.setAttribute("album", parent .album);


This works!






ronandersenAsked:
Who is Participating?
 
objectsConnect With a Mentor Commented:
does Parent have a getAlbum() method?
0
 
ronandersenAuthor Commented:
You answers are not clear on the specific steps to close this question. I assume this question is closed, since it was answered. Therefore, what are you asking me to do??
0
 
ronandersenAuthor Commented:
Answered..created a public getAlbum() method in Parent class and accessed via JSTL for loop.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.