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: Z.BEAT [mailto:zackbeatty@;yahoo.com]
Sent: Thursday, October 17, 2002 1:58 PM
To: Tomcat Users List
Subject: expression ALWAYS evaluates to "if"... NEVER to "else"


In the following code snippet, the expression ALWAYS
evaluates to the "if" statement block:

String paramPassword =
request.getParameter("paramPassword");
String secretCode = "secret";

if(paramPassword != secretCode)
{

}
else
{

}

However, my debugging flags that I send in an HTML
comment CLEARLY show that the two variables have the
same value:

<!-- DEBUG FLAGS
paramPassword: secret
   secretCode: secret
-->

What is going on?   Am I missing something obvious?

Thanks!

__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

--
To unsubscribe, e-mail:
<mailto:tomcat-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail:
<mailto:tomcat-user-help@;jakarta.apache.org>

Reply via email to