• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reg EL

 
Shruthi Karthick
Ranch Hand
Posts: 45
  • 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}

Ans given : false false

It should be true true right?
why the option is false false?
Whether variables i,j are not visible to EL? if so why?
please clarify
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whether variables i,j are not visible to EL? if so why?

That's right. Scripting variables and EL scoped variables are different. You cannot use scripting variables in EL, unless you explicitly set them in a scope. If you had <c:set var="i" value="1"/>, it would be ok, as it would set a page scope variable called "i" whose value is "1". (same for j)
 
Joshua Antony
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
${1 lt 2} should return true, right?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's right, so the answer should be "false true"
 
Shruthi Karthick
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i understood.. thanks Christophe..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic