http://com.example/myServlet.jsp?number=three&number=four
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Vijitha Kumara wrote:Best way to learn these is by testing these code yourself. And what you don't understand; the operators/keywords used?
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
http://com.example/myServlet.jsp?number=three&number=four
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Abimaran Kugathasan wrote:Please confirm!
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
If I correct, ${not map.d} will evaluate to ${not "1"}, and In logical operations, El treats the unknown variable as false. So not false = true!
JSP.2.3.6.2 Unary not operator - {!,not} A
Coerce A to Boolean, apply operator
JSP.2.8.5 Coerce A to Boolean
• If A is null or "", return false
• Otherwise, if A is a Boolean, return A
• Otherwise. if A is a String, and Boolean.valueOf(A) does not throw an exception return it
• Otherwise, error
java.lang Class Boolean
public static Boolean valueOf(String s)
Returns a Boolean with a value represented by the specified string. The Boolean returned represents a true value if the string argument is not null and is equal, ignoring case, to the string "true".
Frits Walraven wrote:Hi Abimaran,
If I correct, ${not map.d} will evaluate to ${not "1"}, and In logical operations, El treats the unknown variable as false. So not false = true!
It is a good explanation, here the lines in the specification to follow:
JSP.2.3.6.2 Unary not operator - {!,not} A
Coerce A to Boolean, apply operator
and if we Coerce A to a Boolean the following applies:
JSP.2.8.5 Coerce A to Boolean
• If A is null or "", return false
• Otherwise, if A is a Boolean, return A
• Otherwise. if A is a String, and Boolean.valueOf(A) does not throw an exception return it
• Otherwise, error
So how does Boolean.valueOf() act in case of String which doesn't contain a boolean:
java.lang Class Boolean
public static Boolean valueOf(String s)
Returns a Boolean with a value represented by the specified string. The Boolean returned represents a true value if the string argument is not null and is equal, ignoring case, to the string "true".
It returns false for every String not equal to "true" (ignoring case)
and here you have your proof
Regards,
Frits
Malika Ben Aziz wrote:
So If I understand you, it just knows that the string "true" is evaluated to the boolean true operator
Every thing else with double quotes is "false"
So ${"true" and "false"} is just like ${ true and "unknowStringWhichWillBeFalse"}
Am I correct?
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Abimaran Kugathasan wrote:Thanks a lot Frits! I just guess it, but you gave the Specification. Thanks for conforming it! My doubt is clear now regarding EL!
Malika Ben Aziz wrote:
So If I understand you, it just knows that the string "true" is evaluated to the boolean true operator
Every thing else with double quotes is "false"
So ${"true" and "false"} is just like ${ true and "unknowStringWhichWillBeFalse"}
Am I correct?
Yea, It's in the Boolean.valueOf(String) method! If anything, other than true, will be false! It'll be safe for us!
Thanks to All!
Honk if you love justice! And honk twice for tiny ads!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|