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 count on the "==" operator to compare an object to null
or to compare simple data types such as int, boolean, long, etc....
Jake
Thursday, October 17, 2002, 12:57:35 PM, you wrote:
ZB> In the following code snippet, the expression ALWAYS
ZB> evaluates to the "if" statement block:
ZB> String paramPassword =
ZB> request.getParameter("paramPassword");
ZB> String secretCode = "secret";
ZB> if(paramPassword != secretCode)
ZB> {
ZB> }
ZB> else
ZB> {
ZB> }
ZB> However, my debugging flags that I send in an HTML
ZB> comment CLEARLY show that the two variables have the
ZB> same value:
ZB> <!-- DEBUG FLAGS
ZB> paramPassword: secret
ZB> secretCode: secret
-->>
ZB> What is going on? Am I missing something obvious?
ZB> Thanks!
ZB> __________________________________________________
ZB> Do you Yahoo!?
ZB> Faith Hill - Exclusive Performances, Videos & More
ZB> http://faith.yahoo.com
ZB> --
ZB> To unsubscribe, e-mail: <mailto:tomcat-user-unsubscribe@;jakarta.apache.org>
ZB> For additional commands, e-mail: <mailto:tomcat-user-help@;jakarta.apache.org>
--
Best regards,
Jacob mailto:hoju@;visi.com
--
To unsubscribe, e-mail: <mailto:tomcat-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@;jakarta.apache.org>