wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Valid operands in a EL expression? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Valid operands in a EL expression?" Watch "Valid operands in a EL expression?" New topic
Author

Valid operands in a EL expression?

Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
When we use arithmetic/logical/Relational operators in EL,what are valid operands we can use? On page 393 of HFSJ it was given

${num>2}
${integer le 12}

where num and integer were String and Integer type respectively ! stringType>2 throws error in java.How to know what types are valid and what types are not valid for operands in EL?

Thanks
Veena
[ April 06, 2006: Message edited by: Veena Point ]

SCJP1.4
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill
Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
Can someone please answer this question?
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

I am trying to give the answer to your question.

Before going to the operators we summerize the conversion rules.
Boolean can be converted to only String.
Character Can converted to Number and String.
Number ( number in Wrapper or constants ) can be converted to Character and String.
String can be converted to Number,Characher and Boolean.

Arithmatic Operators.

In general binary operations, the value are coerec to highest type and operatio is performed. The operand first converted to numeric as per conversion rules then the operator is applied. If the operator result in exception, error is thrown. ( e.g. If the String value can not converted to numeric, it is error)

Relational Operators.
Operates on Numeric, String (lexical), and comparable.


Logical Operators
Operates on boolean values. Coerce both operands to Boolean and apply the operator ( only string other than boolean can be converted to boolean).

${num>2}
${integer le 12}

In this example you are using numeric constants, so it is numeric comparision. The string value in num will convert into number.In the second example the value of wrapper class is used for comparision.

Hope it help you. Any additions welcomed.

Thanks
[ April 07, 2006: Message edited by: Narendra Dhande ]

Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
Thanks Narendra.You meant converted or casted?conversion rules are applies\d or casting rules?
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

I think it is not casting. The Specification use the word "coerec".

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Valid operands in a EL expression?
 
Similar Threads
++ -- Operators
Evaluating EL
confusion in Expression Language
EL and Accessing request scope attributes
valid places where we can put EL?