• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

EL expressions

 
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does the JSP Spec have to say about this?
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic