jQuery in Action, 3rd edition
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
JavaRanch » Java Forums » Java » JSP
Bookmark "EL Logical Operator type conversion" Watch "EL Logical Operator type conversion" New topic

EL Logical Operator type conversion

Devang Ganatra

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

Joined: Jan 10, 2002
Posts: 63858

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

[Asking smart questions] [About Bear] [Books by Bear]
Stefan Evans

Joined: Jul 06, 2005
Posts: 1580
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.

I agree. Here's the link: http://aspose.com/file-tools
subject: EL Logical Operator type conversion
It's not a secret anymore!