• 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

c:set tag with and without body

 
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assuming myMap is a java.util.Map with String as key and Object as value. Are they 100% equivalent?

versus


I tested it with tomcat5.0 and it seems that the EL inside a tag body is converted to String first before assigned to the map. Is there any way to preserve the original type of myObject while using the version with a body?
[ September 05, 2005: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. When an EL expression is used in template text, its behavior is to be evaluated, that value converted to string, and then emitted to whatever writer is in scope at the moment -- in this case, the writer for the tag body. By the time the tag gets the body context, the value has been been long ago converted.

Also note that the whitespace within the tag body -- line terminators and indentation -- are included as part of the tag body in your second example.
[ September 05, 2005: Message edited by: Bear Bibeault ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic