Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 67750
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.
 
Sasparilla and fresh horses for all my men! You will see to it, won't you tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic