The class that my bean uses has an array textFields[407]. I have 407 textfields in my jsp file. I used a loop to make the textfields. So, it looks something like this:

<%for ( int i = 0; i < lineCount; i++ ) {%>
<INPUT TYPE="TEXT" NAME="textFields"+i SIZE="4" MAXLENGTH="7" VALUE=<%= transaction.getTextField(i)%>>
<%}%>

The problem lies in the NAME. What should be its syntax so i can say that I am passing the value of the ith textField in the jsp file to the ith element of the array in the bean?

Is this possible? or should I do another kind of approach?

please help me. :'(

I tried:
NAME="textFields["+i+"]"
NAME="textFields["+<%=i%>+"]"
NAME="textFields"
NAME="textFields[<%=i%>]"

I'm running out of ideas. Could this approach be impossible? but it would be hell if I am gonna give 407 unique names in the bean for the 407 textFields. That isn't approprite. there should be an easier way. :'(

The given code might help...

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="person.Person" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<%
	Person [] persons = new Person[3];
	persons[0] = new Person("aaa","aa","dfdd");
	persons[1] = new Person("vvv","vvv","dfgd");
	persons[2] = new Person("ggg","gg","dty");
%>
<body>
	<%
		int i=0;
		for( i=0; i<persons.length; i++){
			String firstName = persons[i].getFirstName();
			%>
			<input type="text" name='f<%=i%>' value="<%=firstName%>">
			<br>
			<%
		}
	%>
</body>
</html>
This article has been dead for over six months. Start a new discussion instead.