File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes struts iterate tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts iterate tag " Watch "struts iterate tag " New topic

struts iterate tag

li xiaohua

Joined: Nov 04, 2002
Posts: 2
I set the 'loginForm' Object which contains the array of 'userForm' objects (userList) in request
when i want to use the Struts iterator tag to loop the list and print out property 'name',
i am getting following error.
<Error> <HTTP> <101017> <[ServletContext(id=5981 name=DefaultWebApp,context-path=)]
Root cause of ServletException
javax.servlet.jsp.JspException: Cannot find bean userForm in scope null
at org.apache.struts.util.RequestUtils.lookup(

Here is the code:
<logic:iterate id="loginForm" name="loginForm" scope="request" property="userList">
<tr >
<bean:write name="userForm" property="name" />

Can you explain me what went wrong?
Is it required for all of the'userForm' to be set in request/session too?
Any comments will be highly appreciated
Art choz

Joined: Oct 11, 2002
Posts: 5
I think that your error is in the "name" property of the write tag, it must be the name of the "id" tag of the iterate.
gool luck.

Thanks.<br />Arturo Chozas<br />INFORMA S.A.
li xiaohua

Joined: Nov 04, 2002
Posts: 2
problem fixed
thanks ,you are right
Tim Eyre

Joined: May 20, 2002
Posts: 20
I have exactly the same problem, but my bean:write name attribute is pointing to my logic:iterate id attribute:
<logic:iterate id="rep" name="user" property="reports">
<td align="left">
<bean:write name="rep" property="name" filter="true"/> </td>
<td align="left">
<bean:write name="rep" property="description" filter="true"/> </td>
My report bean is defined as follows:
public class Report {
String name = "REPBEAN";
String description = "Empty report bean";
Report(String name, String description) { = name;
this.description = description;
public void setName(String name) { = name;
public String getName() {
public void setDescription(String description) {
this.description = description;
public String getDescription() {
return this.description;
public String toString() {
return "Report: " + name + ", Description: " + description;
And my User bean is:
public class User implements Serializable {
private String username = null;
private Report[] reports = null;
User (String username) {
this.username = username;
public String getUsername() {
return this.username;
public void setUsername(String username) {
this.username = username;
public void setReports(Report[] reports) {
this.reports = reports;
public Report[] getReports() {
return this.reports;
And they get populated by the following code:
User u = new User("timmy");
Report r1 = new Report("this", "works");
Report r2 = new Report("this", "works too");
Report reps[] = new Report[2];
reps[0] = r1;
reps[1] = r2;
HttpSession session = request.getSession();
session.setAttribute("user", u);
Any ideas? I've tried every combination of the scope attribute, but I still get:
"Cannot find bean rep in scope ???"
Thanks for any help you can give.
[ November 26, 2002: Message edited by: Tim Eyre ]
I agree. Here's the link:
subject: struts iterate tag
It's not a secret anymore!