I have an ArrayList in JSP that is storing values that I have from exploding a string. These values are numbers. I can print the Arraylist out to the page just fine and I can also access individual values just fine. However, when I go to put the ArrayList in a for loop to loop through the values the page will not load(how the serer is set up).
Here's the code for what I am trying:
String dds = request.getParameter("dds");
//"1,2,3,4,5,6,7";
String ddm = "this";
ArrayList ddr=new ArrayList();
if(dds == "null" || dds == null){
ddr.add("99");
}else{
String[] ddq = dds.split(",");
int g = 0;
for(g=0;g<ddq.length;g++){
ddr.add(ddq[g]);
}
}
This works fine and then here are the things I have tried that work (for my tests I just made the ArrayList = 1,2,3,4,5,6,7,8):
int h=0;
for(h=0;h<ddr.size();h++){
if(h>0){
out.print(","+ddr.get(h));
}else{
out.print(ddr.get(h));
}
It also works if I just call:
ddr.get(0)
But the when I try to throw it in an if statement it does not work. Like so:
int h=0;
for(h=0;h<ddr.size();h++){
if(ddr.get(h) == i){
out.print("This does not work");
}
}
Also I have tried converting it to an int:
if(Integer.parseInt(ddr.get(h)) == i)
But this just leads to the page not loading again.
This may be something simple and I'm just missing it. But I'm just trying to add a feature to preexisting code I didn't make in the first place. Thanks for any help beforehand.