Hello
I have a vector where I am adding some data to but it doesn't let me do it the way i think it should work. What am i doing wrong. As you can see it doesn't let me add the second value to the first slot of the second vector. Item number one is added in stead.
The code is below with the outPut.
try {
submitRechargeFormData submitData = new submitRechargeFormData();
String splitSizeString = (String) session.getAttribute("splitSize");
int splitSize = Integer.parseInt(splitSizeString);
Vector addData = new Vector();
Vector data = new Vector();
for(int i = 1; i <= splitSize; i++) {
String reason = request.getParameter("reason" + i);
System.out.println("What is reason " + reason);
String entity = request.getParameter("entity" + i);
String costCenter = request.getParameter("costCenter" + i);
String location = request.getParameter("location" + i);
String account = request.getParameter("account" + i);
addData.addElement(reason);
System.out.println("Went into vector " + reason);
System.out.println("this is first element " + (String) addData.firstElement());
addData.addElement(entity);
addData.addElement(costCenter);
addData.addElement(location);
addData.addElement(account);
data.addElement(addData);
}
session.setAttribute("rechargeData", data);
String reason = (String)(((Vector)data.elementAt(0)).elementAt(0));
String reason2 = (String)(((Vector)data.elementAt(1)).elementAt(0));
System.out.println("first one : " + reason);
System.out.println("second one : " + reason2);
////////////////////////////////////////////
outPut
What is reason one
Went into vector one
this is first element one
What is reason two
Went into vector two
this is first element one
What is reason three
Went into vector three
this is first element one
first one : one
second one : one