[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

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!






0
ronandersen
Asked:
ronandersen
  • 2
1 Solution
 
objectsCommented:
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now