File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes EL expressions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "EL expressions " Watch "EL expressions " New topic

EL expressions

mysha ahamed

Joined: Aug 03, 2005
Posts: 22
I am learning EL n have some basic dbts..

List list=new ArrayList();

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


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..
Paolo Metafune
Ranch Hand

Joined: Aug 22, 2005
Posts: 34
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 .

[ August 22, 2005: Message edited by: Paolo Metafune ]
I agree. Here's the link:
subject: EL expressions
It's not a secret anymore!