Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About Head First Chapter 8 mock exam

 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In HF book, mock exam of chapter 8, question 1:

Given HTML form that uses checkboxes to allow a user to select multiple values fro a parameter called hobbies. Which EL return the first value of hobbies?

The answers are :
${param.hobbies}
${paramValues.hobbies[0]}


Option D: ${paramValues[hobbies][0]}
Why this does not work?
According to p.379 example musicMap["Ambient"] is the same as musicMap.Ambient.
paramValues is a map and hobbies is the key. This hobbies key contains a string array.
So, based on this theory, option D should work.
 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I know why.
Let me try ${paramValues["hobbies"][0]} to see if that works.
 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To answer my own question, this is my JSP:


The answer is Yes. ${paramValues["hobbies"][0]} and ${paramValues.hobbies[0]"}
return the same values.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic