Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Specifying Object Type in Tag Body  RSS feed

Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We can specify a rtexpr attribute, say, ${m} which evaluates to some non-String object type, in the body of a tag - instead of inside the tag e.g.

copied from HFS P446, assuming person is a Map. Or, using <jsp:attribute>

assuming the tag file does accept an attribute with rtexprvalue.

In both cases, the attribute of tag is specified in the body. However, when I tested it out myself in tomcat 5.0.29, I noticed that the type of the expression is always converted to String if it is specified in the body - while it remains as the original non-String object if you put it inside the tag. I don't understand why this is the case. I suppose the two ways should produce the same result.

Also, the first question of p447 of HFS says the body version of <c:set> is the same as the non-body version. So, I just want to verify if anybody got the same result. Am I making some mistake?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!