It is acting correclt. Both user and "admin" are java objects, and they are
not the same one, even though they have equivalent string values. Object
equivalence is what == tests. The test you want is :
if (user.equals("admin"))
{
}
Regards,
Paul
-----Original Message-----
From: Winnie Cheung [mailto:[EMAIL PROTECTED]]
Sent: Saturday, November 18, 2000 12:55 AM
To: [EMAIL PROTECTED]
Subject: getParameter is NOT a string?
Hi I am getting a form field (POSTed form) as
String user = (String) request.getParameter("user");
When I out.print this, it writes the correct value, but when i COMPARE this
in an IF condition, it doesnt work. Any reason why? For example, lets say
the "user" textfield in my form is "admin".
Now when I grab it using getParameter, the value printed out is admin!! But
when I do this condition:
if (user == "admin")
{
}
then it doesnt go into this condition, but goes into the ELSE instead!!!
Why is this?
Would appreciate any help..thanks!!