Solved

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

Posted on 2007-11-27
3
494 Views
Last Modified: 2013-11-24
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
Comment
Question by:tiger0516
  • 2
3 Comments
 
LVL 1

Author Comment

by:tiger0516
ID: 20357270
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
 
LVL 1

Author Comment

by:tiger0516
ID: 20357272
What's the better way to do it by using just struts tags?
0
 
LVL 14

Accepted Solution

by:
boonleng earned 50 total points
ID: 20358772

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

    <bean:write name="test/>

</logic:iterate>

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Convert BufferedReader to File 1 63
java continue statement 10 74
changeXy challenge 13 58
noX challenge 17 76
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now