Re: [OT] "if" don't work?!?!?

2007-05-22 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Chuck,

Caldarale, Charles R wrote:
>> From: Christopher Schultz [mailto:[EMAIL PROTECTED] 
>> Subject: Re: [OT] "if" don't work?!?!?
>>
>> String Pippo = "on";
>>
>> if(Pippo == "on")
>>System.err.println("Pippo is on, man!");
> 
> Again, that's not what the OP coded; Pippo was retrieved from the
> request, not set to a constant.  Changing the context of the if
> statement can certainly changes the result.

Agreed. Your quote, however, was out of context. You only showed the
comparison between a (most likely String) reference type and a literal
string and asserted that it was guaranteed not to work. In that context
(i.e. none), your statement was not true.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD4DBQFGU0vc9CaO5/Lv0PARAptfAJd/xAWaVEtfhSAnSYhGMvKGqpEVAJ9KE5hq
BvycOhmewUhMklkNDbeatg==
=wizm
-END PGP SIGNATURE-

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [OT] "if" don't work?!?!?

2007-05-22 Thread Caldarale, Charles R
> From: Christopher Schultz [mailto:[EMAIL PROTECTED] 
> Subject: Re: [OT] "if" don't work?!?!?
> 
> String Pippo = "on";
> 
> if(Pippo == "on")
>System.err.println("Pippo is on, man!");

Again, that's not what the OP coded; Pippo was retrieved from the
request, not set to a constant.  Changing the context of the if
statement can certainly changes the result.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] "if" don't work?!?!?

2007-05-22 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Chuck,

Caldarale, Charles R wrote:
>> From: Massimiliano PASQUALONI 
>> [mailto:[EMAIL PROTECTED] 
>> Subject: "if" don't work?!?!?
>>
>>if (Pippo == "on") {
> 
> Guaranteed to be false.

Not always:

String Pippo = "on";

if(Pippo == "on")
   System.err.println("Pippo is on, man!");

...will print the string ;)

But, of course, this is a /super/ special case where Java's constant
pool is involved. Someone who doesn't understand why "Pippo == "on"
doesn't always work is going to have their mind blown by the constant pool.

- -chris

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGUzc99CaO5/Lv0PARAoktAJ0aTbR2XlrB3CD6PjMUlEsJMIO0pwCgn1zy
SwD0cbGDStbYkxoYtcummaI=
=J+fl
-END PGP SIGNATURE-

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [OT] "if" don't work?!?!?

2007-05-22 Thread Caldarale, Charles R
> From: Jost Richstein [mailto:[EMAIL PROTECTED] 
> Subject: Re: [OT] "if" don't work?!?!?
> 
> No, that is not guaranteed to be false.
> For example
>Pippo.intern() == Pluto.intern()
> should be true.

The above certainly is correct, but is not what the OP coded.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] "if" don't work?!?!?

2007-05-22 Thread Jost Richstein

No, that is not guaranteed to be false.
For example

  Pippo.intern() == Pluto.intern()

should be true.

Caldarale, Charles R schrieb:
From: Massimiliano PASQUALONI 
[mailto:[EMAIL PROTECTED] 
Subject: "if" don't work?!?!?


   if (Pippo == "on") {



Guaranteed to be false.

  

Pippo =  request.getParameter("abilitato");
Pluto =  request.getParameter("abilitato");
 
the if (Pippo == Pluto )  don't work!



Also guaranteed to be false.

You need to learn Java before embarking on writing webapps for any
container.  The test you're making is one for object equality, not
content equality.  Your expression should be something like:

if (Pippo.equals("on"))

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




  


--
Jost Richstein
SoftDeCC Software GmbH
Email: [EMAIL PROTECTED]
Tel.: +49 89 89 06 78 47
Fax.: +49 89 89 06 78 33

SoftDeCC Software GmbH; Gesellschaft mit beschränkter Haftung; Sitz der 
Gesellschaft: München; Registergericht: München, HRB 123667; Geschäftsführer: 
Ralf Malis, Georg Nüssel, Jost Richstein, Gerd Wilts



-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: OT: "if" don't work?!?!?

2007-05-22 Thread DJohnson
This is not really a Tomcat question, but a matter of Java language 
understanding.
Comparators like ==, >, <=, etc. should only be used with java language 
primitive types, such as int, byte, boolean, and NOT with Objects, like 
String, as you are, UNLESS you actually wish to test whether the two 
things you are comparing are the same object instance.  To test whether 
two distinct objects represent the same value or entity, use the equals 
method.  So in your case, you should use:

if (Pippo.equals("on")) { ... }

or 

if (Pippo.equals(Pluto)) { ... }



Please respond to "Tomcat Users List" 

To: "'Tomcat Users List'" 
cc:  
Subject:"if" don't work?!?!?


Hi guy!

Wat's happen??

If i read an checkrequest post

String Pippo = request.getParameter("abilitato");

out.print(Pippo);

return me= on

If I try to make a condition whit if:



if (Pippo == "on") {



}

these don't work

And is'nt the first time,

if I try

Pippo =  request.getParameter("abilitato");
Pluto =  request.getParameter("abilitato");

the if (Pippo == Pluto )  don't work!



:-(

please, help me!

Massimiliano PASQUALONI

Data Processing S.r.l.
Reparto EDP
S.S. 100 BA-TA Km 18
c/o "IL BARICENTRO"
torre D
70010 CASAMASSIMA (BA)




RE: [OT] "if" don't work?!?!?

2007-05-22 Thread Caldarale, Charles R
> From: Massimiliano PASQUALONI 
> [mailto:[EMAIL PROTECTED] 
> Subject: "if" don't work?!?!?
> 
>if (Pippo == "on") {

Guaranteed to be false.

> Pippo =  request.getParameter("abilitato");
> Pluto =  request.getParameter("abilitato");
>  
> the if (Pippo == Pluto )  don't work!

Also guaranteed to be false.

You need to learn Java before embarking on writing webapps for any
container.  The test you're making is one for object equality, not
content equality.  Your expression should be something like:

if (Pippo.equals("on"))

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]