Modifying java array within a JSP input form -
i trying modify java array within <input> tag in jsp
string[] userproperties = {"one", "two", "three"}; string[] propvalues = new string[userproperties.length]; . . . <% for(int = 0; < userproperties.length; i++) { %> <tr> <td> <input type="text" size="30" maxlength="150" name="<%=propvalues[i]%>" value="somevalue"> </td> </tr> <% } %> . . . i there 3 input forms in example, , each form, value entered user bound appropriate position in propvalues array once submit button clicked. modifying based on older code had name set local java variable, , successful in being able modify variable. not possible arrays in jsp? aware jstl has <c:foreach> tag makes simpler, since working single file in aged codebase want keep libraries has access consistent. possible using <%> java code blocks?
//length 3 initialize default value null. string[] propvalues = new string[userproperties.length]; what trying initializing variable userproperties , try access array variable propvalues contains null.
name="<%=propvalues[i]%>" // set name null. so, 3 input have same name null. better try code
<input type="text" size="30" maxlength="150" name="<%=userproperties[i]%>" value="somevalue"> instead of
<input type="text" size="30" maxlength="150" name="<%=propvalues[i]%>" value="somevalue">
Comments
Post a Comment