franklinexpress
franklinexpress

Reputation: 1189

Jsp list output Object@488584?

I have a list of tweets inside a user and when I iterate through them all I get is the object but not the actual text

<c:forEach items = "${tweets}" var="user" ></c:forEach>

  <h1><c:out value="${user.tweets}" /></h1>
  </div>

how do I get the value of the tweets, they all save as text in the databse but don't display properly on the page.

Upvotes: 0

Views: 38

Answers (1)

Master Slave
Master Slave

Reputation: 28519

There are two things I see wrong. First if your code is really as posted and not a typo, than you should note that you don't print anything inside a loop as you just iterate and never do anything with the user variable

The following

<c:forEach items = "${tweets}" var="user" ></c:forEach>

should be something like

<c:forEach items = "${tweets}" var="user" >
   <c:out value="${user.tweets}"
</c:forEach>

Also, I've seen in this other question of yours the structure of your User class. The tweets property is a list, so you should iterate over it just like you iterate the tweets model attribute, so something like

<c:forEach items = "${user.tweets}" var="singleTweet" >
   <c:out value="${singleTweet.tweet}"
</c:forEach>

Upvotes: 1

Related Questions