M
Mike
I have a jsp that is taking data entered into an html form and posting
it to an MS-SQL DB. This is working fine.
Before I post the data I want the jsp to calculate a shipping charge
based on where the person is located. Here is some of my code.
START CODE
String t_state = request.getParameter("state");
String t_postal = request.getParameter("zip");
String t_country = request.getParameter("country");
.......
.......
// Calculate the shipping costs
int shp_cost=0;
if(t_country=="US") {
if(t_state=="AK"||t_state=="HI"||t_state=="PR") {
shp_cost=15;
} else {shp_cost=10;
};
} else if(t_country=="CA"||t_country=="MX") {
shp_cost=15;
} else {
shp_cost=25;
}
END CODE
Right after this I post the t_country, t_state and shp_cost to my db
and that posts everything correctly.
My problem is that no matter what I enter into the form for these 2
strings, the shp_cost always comes out =25.
I don't believe that it is the IF/Else statement because if I add
lines like
t_country="US";
t_state="ID";
the If/Else statement works fine and would return in this case
shp_cost=10
So I am thinking that I need to do something else with the 2 strings,
but not sure what. Like I said they post fine to the db, so the data
is assigned to the strings.
Any ideas?
Thanks in advance for the help.
it to an MS-SQL DB. This is working fine.
Before I post the data I want the jsp to calculate a shipping charge
based on where the person is located. Here is some of my code.
START CODE
String t_state = request.getParameter("state");
String t_postal = request.getParameter("zip");
String t_country = request.getParameter("country");
.......
.......
// Calculate the shipping costs
int shp_cost=0;
if(t_country=="US") {
if(t_state=="AK"||t_state=="HI"||t_state=="PR") {
shp_cost=15;
} else {shp_cost=10;
};
} else if(t_country=="CA"||t_country=="MX") {
shp_cost=15;
} else {
shp_cost=25;
}
END CODE
Right after this I post the t_country, t_state and shp_cost to my db
and that posts everything correctly.
My problem is that no matter what I enter into the form for these 2
strings, the shp_cost always comes out =25.
I don't believe that it is the IF/Else statement because if I add
lines like
t_country="US";
t_state="ID";
the If/Else statement works fine and would return in this case
shp_cost=10
So I am thinking that I need to do something else with the 2 strings,
but not sure what. Like I said they post fine to the db, so the data
is assigned to the strings.
Any ideas?
Thanks in advance for the help.