Improve company productivity with a Business Account.Sign Up

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

bean:write on a Collection (Set<String>)

In my Action, I have: request.setAttribute("book", book);

book is a Book object, which has a getAuthors method. getAuthors
returns a collection (Set<String>)

in JSP page, I want to list authors one by one. How shall I do?

<bean:write name="book" property="authors" /> does not work as I want.

Thanks,
0
tiger0516
Asked:
tiger0516
  • 2
1 Solution
 
tiger0516Author Commented:
I barely made it work by using jsp and bean:define.

<bean:define id="test" name="book" type="org.lonetree.tc.core.Book" />
  <%
  Iterator<String> itr=test.getAuthors().iterator();
  while (itr.hasNext())
  {
        out.println(itr.next());
        out.println("<br>");
  }
        %>
0
 
tiger0516Author Commented:
What's the better way to do it by using just struts tags?
0
 
boonlengCommented:

<logic:iterate id="test" name="book" property="authors">
    <bean:write name="test/>
</logic:iterate>

Open in new window

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.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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