Win a copy of Functional Design and Architecture this week in the Functional programming forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

EL Implicit object paramValues

 
Ranch Hand
Posts: 77
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have request parameterd called name who has multiple values say "Imran" & "Vohra".

Now, when I am writing,
${paramValues.name[0]} -> its printing "Imran"
${paramValues.name} -> its printing String[] Object reference
${paramValues[name]} -> its not working.
${paramValues[name][0]} -> Its not working

I am confused in last two. Why its not working? Whats wrong?
Please help me.

Imran
 
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


${paramValues[name]} -> its not working.
${paramValues[name][0]} -> Its not working



It's not working because when using EL, everything you put within brackets is evaluated first if it's not within quotes.

So, in the last two examples you provided above, the container tries to find an attribute called as name in either page, request, session or application scopes and NOT a param as you would expect.
 
Imran Vohra
Ranch Hand
Posts: 77
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh.....I got it
Thanks
In [] operator if quotes are not there then it must be either implicit object or key(for Map) or index(for List and Array) or property (for bean).
I hope I am right this time.

Thanks once again
Imran
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you left what Edisandro Bessa said.
its an attribute.if you dont have quotes.
better verify pg number 375 in hfsj.
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Imran,

In [] operator if quotes are not there then it must be either implicit object or key(for Map) or index(for List and Array) or property (for bean).



Wrong.

1. If quotes are there, it can be a Map key or a bean property or an index (for List and Array)
2. If quotes are not there, it can be attribute or an index (for List and Array)
 
Imran Vohra
Ranch Hand
Posts: 77
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks....for correcting me.

Imran
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in the aboue case ${paramvalues.name} should print "imran" right??
can anybody correct me if i am wrong!!
thanks,
regards
krishna!!
 
Imran Vohra
Ranch Hand
Posts: 77
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, ${paramValues.name[0]} will print "Imran".
Because ${paramValues.name} will return an array.

Thanks
Imran
 
Edisandro Bessa
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


No, ${paramValues.name[0]} will print "Imran".
Because ${paramValues.name} will return an array.



Incorrect !

Whenever you use ${paramValues.name} whithout specifying an index, ALWAYS will be returned the first element of the array.
 
Imran Vohra
Ranch Hand
Posts: 77
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this time I am not wrong.
If you write
${param.name}
then it will print first element, but if you write
${paramValues.name} then it will not print first element.

I have tested that with Tomcat 5.0



And my URL was



Its printing object reference.

Please confirm the same.

Thanks
Imran
 
Edisandro Bessa
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh yeah, you're correct.

My explanation above is valid only when using the following statement :

${param.name}

In this case, if name is has more than one value, the statement above will return the first element.

But if you use ${paramValues.name} the toString() version will be called instead.

Very good discussion.
[ August 24, 2006: Message edited by: Edisandro Bessa ]
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic