• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

visibility of variables in EL

 
vani venkat
Ranch Hand
Posts: 142
  • 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 : false true.


given Explanation is i and j are not visible to EL here.



I can print them using jsp expression or scriptlet.
1. why are they not visible to EL?
does it mean only attributes set in servlets as request, session, page, application can be viewed by EL and other variables declared in other scriptlets of jsp are not visible? or should we use EL only to access nested objects(or properties) of the four scopes?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By design, scripting variables have nothing whatsoever to do with the EL.

The JSTL and EL are meant to replace scriptlets, not work with them.
 
vani venkat
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks .. i am thinking of scenario in which all of the scriptlets are being replaced by EL. I think it is not that easy if jsp has variables declared in scriptlets.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic