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 "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>


--
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