• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

EL expressions

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<% int[] num={11,22};
request.setAttribute("attr",num); %>

${requestScope["attr"][0]}
/-------------------------------------/

how does this EL expression evaluvates?

requestScope.attr[0]

requestScope.attr evaluavtes to num object.so the above expression will be evaluvated as ${num[0]} ..is it true?
If so can the object be directly used in a EL expression ..instead of a Attribute name?
 
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
${requestScope.attr[0]} and ${requestScope["attr"][0]} both will evaluate to ${num[0]} and will print "11". Yes you can use ${attr[0]} directly and the output will be same but you can't use ${num[0]} because the EL searches the used attribute in different scopes starting from page then request,session and application, so "attr" will be found in request scope whereas there is no attribute in any scope by the name of "num".
 
Sophie Angela
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much
 
A tiny monkey bit me and I got tiny ads:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic