• 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

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a person bean with name property. So in my JSP to get the name using EL

${requestScope.person["name"]}

How can I get the same result without using the dot operator and only using the [] operator.

I am doing something like this but this doesn't work
${requestScope[person["name"]]}
 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, this is a tricky and good question.

requestScope - a java.util.Map that maps request-scoped attribute names to their values.

If you want to use [] operator on the requestScope Map, the value evaluated for the expression used within the [] should be available as "key" for any object stored in the request scope. For example, look at the following JSP:



The output is:

Here person["name"] is evaluated to "Sangeetha" which in turn is the key for object "list" stored in the requestScope Map.

Thanks,

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

I am doing something like this but this doesn't work
${requestScope[person["name"]]}

To put it another way, evaluates to a Person object, not the string "person." The object must be turned into a map key for requestScope. The object is not evaluating to the string you expect.
[ February 23, 2005: Message edited by: P. Dunn ]
 
Who knew that furniture could be so violent? Put this tiny ad out there to see what happens:
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