• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

${empty}

 
Kanishka Ajwani
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question from Whizlabs, practice exam 2, Q 25.

Which of the following fragments would produce result true?

a) ${empty null}
b) ${empty 0}
c) ${empty pageContext}
d) ${empty param}


The answers are A and D. I did not understand why D would produce true. "param" is an implicit object in EL which is a map containing the request parameters. Even if there are no request parameters in the query string, param is a valid map object. Why will ${empty param} produce true?

Thanks.
Kanishka
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2536
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kanishka,

According to the jsp(1.1) specs
JSP.2.3.7 Empty Operator - empty A
The empty operator is a prefix operator that can be used to determine if a value is null or empty.
To evaluate empty A:

  • If A is null, return true,
  • Otherwise, if A is the empty string, then return true.
  • Otherwise, if A is an empty array, then return true.
  • Otherwise, if A is an empty Map, return true,
  • Otherwise, if A is an empty Collection, return true,
  • Otherwise return false.


  • Regards,
    Frits
     
    Kanishka Ajwani
    Ranch Hand
    Posts: 62
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks Frits, I should have read the specs carefully. Thanks again.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic