• 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

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am learning EL n have some basic dbts..

List list=new ArrayList();
list.add("list1");
list.add("list2");

Map tmap=new TreeMap();
tmap.put(new Integer(1) ,"map1");
tmap.put(new Integer(2),"map2");

request.setAttribute("li",list);
request.setAttribute("tma",tmap);

request.setAttribute("va",new Integer(1));

list : ${li[va]}<br> //line 1
map : ${tma[va]}<br> //line 2

My dbout is, in line 1 the attribute "va" shuld be evaluated to a primitive value (index of list) n in line 2 the same attribute "va" shuld be evaluated to an Integr object (treemaps expect comparable objects as keys)..So I dont understand how these attributes to object mappings (attribute "va"->Integer Object (1)) are evaluated in EL .
Can anyone pls clear my dbt..
Thnx..
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The jsp 2.0 specification answer your question (see Part 1 Expression Language, .2.3.4 paragraph)

However, for mapping in line 1 the Integer reference "va" is coerced to int
and for mapping in line 2 the Integer reference "va" is normally used as map key to retrieve the value .

Bye
[ August 22, 2005: Message edited by: Paolo Metafune ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic