• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL from HFSJ

 
kapil munjal
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was going through chapter 8 of HFSJ and came through this EL
on page 394.

${requestScope[integer] ne 4 and 6 le num || false}

This whole expression return false but I am not able to find out how.

Could someone explain!
 
J Johny Rufus
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kapil Munjal,

"${requestScope[integer] ne 4 and 6 le num || false}"

can be splitted into three subsets,

1. requestScope[integer] ne 4 AND
2. 6 le num OR
3. false

so, if either 1 or 2 evaluates to false , then the expression becomes

1) either as false AND true OR false --> false OR false --> FALSE
2) or as true AND false OR false --> false OR false --> FALSE

Hope this helps

Thanks and Regards,
Rufus
 
kapil munjal
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Johny,

Could you tell what "requestScope[integer]" will return.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I thnk it will return null. what is about num in the EL?

Thanks
 
kapil munjal
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please go to page 394 of HFSJ and you will find the question.
 
sergio mendez-rueda
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kapil munjal:
Please go to page 394 of HFSJ and you will find the question.

requestScope[integer] return 0 but
requestScope["integer"] or requestScope['integer'] return 3
cheers
 
H Singh
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Sergio:

Can you please explain why would
requestScope[integer] return 0 but
requestScope["integer"] or requestScope['integer'] return 3

Thanks
 
kapil munjal
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please explain why would
requestScope[integer] return 0 but
requestScope["integer"] or requestScope['integer'] return 3


requestScope[integer] return 0

- It will look for a attribute with the name 'integer', and it will find the value of this attribute as 3. But till now this expression has not looked into requestScope. Its just the EL which is being processed. Now, it will look for the 4th element in the requestscope and it will not find anything as there are only 3 elements (0,1,2). So, it will return 0.


But it we do this -
requestScope["integer"] or requestScope['integer'] return 3

It will look for a map value with the key 'integer' and it will find the second key in the map and return the value 3.
 
sergio mendez-rueda
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kapil munjal:


requestScope[integer] return 0

- It will look for a attribute with the name 'integer', and it will find the value of this attribute as 3. But till now this expression has not looked into requestScope. Its just the EL which is being processed. Now, it will look for the 4th element in the requestscope and it will not find anything as there are only 3 elements (0,1,2). So, it will return 0.


But it we do this -
requestScope["integer"] or requestScope['integer'] return 3

It will look for a map value with the key 'integer' and it will find the second key in the map and return the value 3.

Hi Kapil,
your explanation is fine!!

thanks,
sergio
-----
Toto, I don't think we're in Kansas anymore
--Dorothy, from the Wizard of Oz
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic