I'm having a problem with this section of my forms processing.
its a
jsp form which , when submitted passes the values to another jsp page that processes and outputs the results.
Heres the block of code that is giing me the problem:
----------------------------------------------------------------
String typeCombo = request.getParameter("typecombo");
String modelCombo = request.getParameter("modelcombo");
String brandCombo = request.getParameter("brandcombo");
if(modelCombo == "null" && brandCombo == "null" && typeCombo != "null"){
SQLString = "select * from s99661251_Products WHERE type = '" + typeCombo + "'";
showResult(out, request, SQLString);
}
else if(typeCombo == "null" && brandCombo == "null" && modelCombo != "null"){
SQLString = "select * from s99661251_Products WHERE model = '" + modelCombo + "'";
showResult(out, request, SQLString);
}
else if(typeCombo == "null" && modelCombo == "null" && brandCombo != "null"){
SQLString = "select * from s99661251_Products WHERE brand = '" + brandCombo + "'";
showResult(out, request, SQLString);
}
else if(modelCombo == "null" && brandCombo != "null" && typeCombo != "null"){
SQLString = "select * from s99661251_Products WHERE type = '" + typeCombo + "' AND brand = '" + brandCombo + "'";
showResult(out, request, SQLString);
}
else if(typeCombo == "null" && brandCombo != "null" && modelCombo != "null"){
SQLString = "select * from s99661251_Products WHERE model = '" + modelCombo + "' AND brand = '" + brandCombo + "'";
showResult(out, request, SQLString);
}
else if(brandCombo == "null" && modelCombo != "null" && typeCombo != "null"){
SQLString = "select * from s99661251_Products WHERE type = '" + typeCombo + "' AND model = '" + modelCombo + "'";
showResult(out, request, SQLString);
}
else if(typeCombo == "null" && brandCombo == "null" && modelCombo == "null"){
//showComboError = "<font color=red>You need to select at least one critiria!</font>";
}
else{
SQLString = "select * from s99661251_Products WHERE type = '" + typeCombo + "' AND model = '" + modelCombo + "' AND brand = '" + brandCombo + "'";
showResult(out, request, SQLString);
}
--------------------------------------------------------------
where typeCombo, modelCombo, brandCombo will provide a "null" String value if the user does not choose anything from the combobox. Yes, the form just consists of 3 combo boxes.
The problem is, the process seems to always skip to the else{} statement. ignoring the previous if{} and elseif{} statements. What is it that I am doing wrong? (also if i try removing the else statement altogether, the form does not even process)
Thanks.
Ryan