• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 504
  • 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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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