• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL expressions

 
mysha ahamed
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • 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..
 
Paolo Metafune
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic