What you *really* should do is use the Struts "iterate" tag in the logic
TLD. 
Using scriptlet is generally a *bad* thing ... however, if you really wanted
to do this you need to use a JSP expression for the property value like this
...
   Text: <html:text property='<%=names[i]%>'/>


-----Original Message-----
From: Ramakrishna Reddy Kandula [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 16, 2001 9:36 PM
To: [EMAIL PROTECTED]
Subject: indexed property iteration



How do I achieve indexed property access dynamically ?

The following doesn't work.

<html:form name='testForm' type='test.TestForm' action='test.do'>
<%
   TestForm testForm = (TestForm) session.getAttribute("testForm");
   int i = 0;
   for (i=0; i < testForm.getNames().length; i++) {
%>
   Text: <html:text property='names[i]'/>
<%
   }
%>
   <html:submit>Go</html:submit>
</html:form>

It says,
javax.servlet.ServletException: Invalid indexed property 'names[i]'

Thanks,
ramky

Reply via email to