• Post Reply Bookmark Topic Watch Topic
  • New Topic

c:set tag with and without body  RSS feed

 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • 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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66152
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!