wood burning stoves 2.0*
The moose likes JSP and the fly likes EL Logical Operator type conversion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "EL Logical Operator type conversion" Watch "EL Logical Operator type conversion" New topic
Author

EL Logical Operator type conversion

Devang Ganatra
Greenhorn

Joined: Feb 19, 2008
Posts: 5
Hello .
i am using following code in my JSP

${not "Hello"}.

In output it is displayed as true. So i want to know that what is the formula of type conversion for String to Boolean . Because not operator can only be applied to boolean values. so how this String value converted to Boolean value?

Please explain me
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

It isn't really converted. Any value that doesn't have a conversion to Boolean evaluates as false.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
The JSTL rules to coerce something to a boolean value
Coerce A to Boolean
- If A is null or "", return false
- Otherwise, if A is Boolean, return A
- Otherwise, if A is String, and Boolean.valueOf(A) throws exception, error.
- Otherwise. if A is String return Boolean.valueOf(A)
- Otherwise, error

Boolean.valueOf("Hello") evaluates as false.

Cheers,
evnafets
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EL Logical Operator type conversion
 
Similar Threads
Regarding Expression Language
ArrayStoreException
Valid operands in a EL expression?
Boolean unboxing.
String + char concat, what is really going on!?