Don't think this is possible... but- dynamic variable declarations in JSP- ???
Posted on 2001-06-21
I have an array that is made up of the names of all my form fields of the calling page. In the current page I break apart the array into the individual field names.
I then want to in a for loop, declare String variables with the same name as the fields in the array-
// quick attempt at explaining what I'm talking about
String ArrayVal = "Color,Qty,Cost"; //actually passed in String temp = "";
// extract each field name using charAt and substring
temp = ArrayVal.substring(startPos, i);
// I need to code it like this:
String temp = request.getParameter(temp);
//but I actually need it to function like this:
// String Color = request.getParameter("Color");
The problem is that the prior form is dynamically built, so I'll never know which fields will be there...
open to any suggestions.