My apologies for the easy question. I should have
known.
--- [EMAIL PROTECTED] wrote:
> You'll want to do if(
> !(paramPassword.equalsIgnoreCase(secretCode))) { }
> else { }
>
> You cant use logical operators on Strings for what
> you're trying to do!
>
> Look up the java.lang.String javadocs f
ubject: Re: expression ALWAYS evaluates to "if"... NEVER to "else"
Hello Z.BEAT,
If these are both java String objects then all you are comparing is if
the memory location of string object #1 is the same as that of String
object #2. This is probably not true. You
You need to learn how java compares objects and strings. The short story is:
if(!paramPassword.equals(secretCode))
{
}
else
{
}
-Original Message-
From: Z.BEAT [mailto:zackbeatty@;yahoo.com]
Sent: 17 October, 2002 11:58 AM
To: Tomcat Users List
Subject: expression ALWAYS evaluates to "i
Hello Z.BEAT,
If these are both java String objects then all you are comparing is if
the memory location of string object #1 is the same as that of String
object #2. This is probably not true. You need to compare like this.
if (paramPassword.equals(secretCode)) {
} else {
}
You can only coun
You can't use "!=" or "==" to compare Strings.
http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html
You could use something like:
if (paramPassword.compareTo(secretCode) == 0) {
// they match
} else {
// they don't
}
Or flip your "if" around and use .equals():
if (paramPassword
You'll want to do if( !(paramPassword.equalsIgnoreCase(secretCode))) { }
else { }
You cant use logical operators on Strings for what you're trying to do!
Look up the java.lang.String javadocs for more information on the equals and
equalsIgnoreCase methods.
Steve
-Original Message-
From