You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by CPC Livelink Admin <cp...@fitzpatrick.cc> on 2000/11/18 05:59:25 UTC
RE: getParameter is NOT a string?
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:winframe@iname.com]
Sent: Saturday, November 18, 2000 12:55 AM
To: tomcat-user@jakarta.apache.org
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!!