redirection problem...

Hi all, actually i am not sure what's wrong with my redirection servlet script...

part of my servlet code:

if (menu1 !=null){

out.print(menu1);

if (menu1 =="$501-$1000"){

response.sendRedirect("http://www.yahoo.com");

}else{

out.println("Section 2 codes...");

}

ok when i do a out.print(menu1), i got this

$501-$1000;

however why it doesn't enter my if (menu1 == "$501-$1000") Control Structure and redirect me to other site? Can someone explain to me pls... thanks.

[882 byte] By [diskhuba] at [2007-11-26 18:23:58]
# 1
go back to basics..u can compare a string like this...u have equals method to do that..(menu1 == "$501-$1000")if(menu1.equals("$501-$1000"))regardsShanu
mshanua at 2007-7-9 5:58:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

oh My God... thanks Shanu

i thought it's going to be the same as C++...

I am not very good in Java.

but can you explain why == doesn't work?

does it mean that == only works for numbers?

then if i have a string and integer to compare in a flow structure... is the following correct?

if(menu1.equals("$501-$1000") && integ1 == 50)...

Regards,

Chris

diskhuba at 2007-7-9 5:58:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
java primitive type like int , long, double etc...can be compared with == String is an object..:))regardsshanu
mshanua at 2007-7-9 5:58:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...