Would this work for you?
( http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#toLowerCase() )
Javabean:
public boolean StringToBoolean(String StrBool)
{
boolean convertito=false;
// since the default is false, only need to check the true...
// If any of these are true, return true, else return false (on any
string of characters...)
if ((contentEquals(toLowerCase(StrBool) "1")) ||
(contentEquals(toLowerCase(StrBool) "on")) ||
(contentEquals(toLowerCase(StrBool) "yes")) ||
(contentEquals(toLowerCase(StrBool) "si")) ||
(contentEquals(toLowerCase(StrBool) "true")) )
{
convertito = true;
}
return convertito;
}
-----Original Message-----
From: Massimiliano PASQUALONI [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 22, 2007 9:58 AM
To: 'Tomcat Users List'
Subject: R: "if" don't work?!?!?
No, don't work!
Im try a simple function in my javabean that "convert" from string to
boolean:
JSP:
String Prova = request.getParameter("abilitato");
// where abilitato is a checkbox in a form
Javabean:
public boolean StringToBoolean(String StrBool)
{
boolean convertito=false;
if ((StrBool == "0") || (StrBool == "Off") || (StrBool ==
"off") || (StrBool == "No") || (StrBool == "no") || (StrBool == "False")
|| (StrBool == "false"))
{
convertito = false;
}
return convertito;
}
If I try
if ("on".equals(request.getParameter("abilitato"))){
Abilitato = true;
}
Or
if (request.getParameter("abilitato").equals("on")){
Abilitato = true;
}
Or
if (request.getParameter("abilitato") == "on"){
Abilitato = true;
}
Or
Boolean Abilitato = bean.StringToBoolean(Prova);
I have the same result: don't work..
Yesterday I've try also
Referer = request.getHeader("Referer")
AltroReferer = request.getHeader("Referer")
if (Referer == AltroReferer ){...}
And don't work.....
:-O
-----Messaggio originale-----
Da: Edoardo Panfili [mailto:[EMAIL PROTECTED]
Inviato: martedì 22 maggio 2007 16.44
A: Tomcat Users List
Oggetto: Re: "if" don't work?!?!?
Massimiliano PASQUALONI ha scritto:
> 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") {
>
> ............
>
> }
Maybe possible that I don't understand...
String pippo = request.getParameter("abilitato");
if (pippo.equals("on")) {
// ...
}
Edoardo
--
[EMAIL PROTECTED]
AIM: edoardopn
Jabber: [EMAIL PROTECTED]
tel:075 9142766
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected] To unsubscribe,
e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Scanned with Copfilter Version 0.83beta3a (ProxSMTP 1.4)
AntiVirus: ClamAV 0.88.4/3281 - Tue May 22 10:50:43 2007 by Markus Madlener @
http://www.copfilter.org
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected] To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]