Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RTExpr Attribute Value Given in Tag Body

 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sometimes tag attribute value could be specified in the tag body e.g.

can becomes


Or thru the use of <jsp:attribute>

becomes


However, in tomcat 5, if the value is a non-String rt expression, a Rt expression given in the tag body (the second versions above) is toString'ed and the attribute just receives a String instead of an Object type. Is this a behavior defined in spec? I just cannot locate explicit info in the spec saying this but it seems to imply this behavior. Could anyone clarify this. Thanks
 
Stefan Evans
Bartender
Posts: 1778
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it is more implied than stated anywhere.
Anything that is template text, gets output to a writer - it has to be converted to a string.
Values in an attribute are not template text, so obviously do not get automatically converted.

Check out section JSP1.3.6 of the JSP2.0 specification.
It has an example showing that whatever is nested between tags is template text. It also details the <jsp:attribute> tag, which I admit I have never come across before.

Hope this helps,
evnafets
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic