• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFSJ doubt

 
Jitendra Jha
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help me understand why question-19 on page 438, chapter-8, option c is wrong

 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jitendra Jha wrote:Please help me understand why question-19 on page 438, chapter-8, option c is wrong



To avoid wasting someone's time, it's better if you write the question here.
 
Jitendra Jha
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


To avoid wasting someone's time, it's better if you write the question here.


As far as i know,this attitude is not fitting a rancher
if only i could,i would certainly have done it!!!

anyways thanks for your valuable answer
 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jitendra Jha wrote:


To avoid wasting someone's time, it's better if you write the question here.


As far as i know,this attitude is not fitting a rancher
if only i could,i would certainly have done it!!!

anyways thanks for your valuable answer


Please read this.
 
Jitendra Jha
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Treimin Clark wrote:
Jitendra Jha wrote:


To avoid wasting someone's time, it's better if you write the question here.


As far as i know,this attitude is not fitting a rancher
if only i could,i would certainly have done it!!!

anyways thanks for your valuable answer


Please read this.



please read the bold line again
that here refers to the question referred to here
 
Rob Spoor
Sheriff
Pie
Posts: 20753
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Be Nice.

Jitendra, although Treimin may have been too blunt, he* is right. Not everyone has that book, so without you posting the question a lot of people (including me) are not able to help you.


Treimin, if you're a woman, please forgive me ops:
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool down guys Jitendra, as soon as you can get a hand on that question, post it here, so that more ranchers can help you.
 
Jonathan Elkharrat
Ranch Hand
Posts: 170
Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

this is the question:

An online jewelry retailer wishes to customize their online catalog for users who are logged in.
They want to show specials for the user's birthstone month.
The company's special offers are stored as a Map<String, Special[]> identified as specials in application scope and updated daily.
There is a bean stored as a session-scoped attribute named userInfo. Calling getBirthdate().getMonth() on this bean will return the user's birthstone month.
Which of the following code snippets could correctly retrieve the appropriate special offerings?

A. ${applicationScope[userInfo.birthdate.month.specials]}
B. ${applicationScope.specials[userInfo.birthdate.month]}
C. ${applicationScope["specials"].userInfo.birthdate.month}
D. ${applicationScope["userInfo.birthdate.month"].specials}

given amswer: B

why is C wrong?

how would you write it in script?
getServletContext().getAttribute("specials").get(userInfo.getBirthdate().getMonth());

in EL it gives:
${applicationScope.specials[userInfo.birthdate.month]}

don't forget applicationScope is a map so you can access its values either through dot (.) operator or brackets ([ ]).
applicationScope["specials"] return the special map<String,Special[]> all right.
but then we need to get the value associated to the month. answer B do that right.
in answer C there's no use of brackets so the translator would try to find a value associated with the key userInfo first.
remember that if you are not using brackets, expression are evaluated from left to right, as they appear...

for all of you that are still awake, congrats...
 
Jonathan Elkharrat
Ranch Hand
Posts: 170
Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i forgot the casting to map<String,Special[]>, but you got the point....
 
Jitendra Jha
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jonathan Elkharrat wrote:i forgot the casting to map<String,Special[]>, but you got the point....


I did get it Jonathan
Thanks a lot.It was a few hours before exam and it is my principal,as to look at the book during those hours

Treimin Clark
Sorry if i was rude but was under a lot of stress
Thanks anyways


 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not a woman
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic