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

EL expressions

 
dolly shah
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given the following contents of a JSP page what will happen when you

attempt to compile and run it?

<%
int i = 1;
int j =2;
%>

${i < j}
${1 lt 2}

Choose one answer.
a. Compilation error Incorrect
b. output of true true Incorrect
c. output of null true Incorrect
d. output of false true Correct -answer
e. output of true false Incorrect

-The variables i and j are not visible to the EL expression and are thus ignored. The EL expression does not output null.

-I answered "b" which is wrong. How the "d" is the correct answer. Please clear my doubt.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65339
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does the JSP Spec have to say about this?
 
Phani Burra
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
${i < j} in this case since you say that i and j variables are not visible to EL expression, their values are defaulted to 0 since it a arithmetic expression in an EL expression. So the 0<0 would result in false.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic