• 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

Need Tips for JSP EL

 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can any one tell the tips for JSP Expression Language, I got confused of using [] and . I am losingmarks in this area in mock up exams.

Thanks In Advance,
Deepak........
 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
only one thing: is more specific than : you can use the first one in place of the second one, but the opposite is not true.
 
Deepak Mula
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You Mirko
 
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One huge gotcha for me was...

using quotes "" in [] while using map or bean attribute

For a key of a map or a property of a bean attribute you have to use "" quotes in the [] eg: ${bean["property"]} or ${map["key"]}. Only instance where you CAN use no quotes is when you store the key (if its a map) in an attribute or property (if its a bean) in an attribute.

For eg:

String property = beanclass.getProperty();

request.setAttribute("example", property) and then

${bean[example]} <-- see no "" quotes used.

2nd eg:

Map abc = new HashMap();
abc.put(key, "whatever");

request.setAttribute("example2", key) and access the map's key by

${map[example2]} <<- again no "" quotes used here

using ${bean[property]} or ${map[key]} is not correct because i have not used quotes.



incase of lists and arrays you can use quotes or no quotes in []...

eg: ${array[1]} or ${array["1"]} both are correct.
 
A feeble attempt to tell you about our stuff that makes us money
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic