Some one knows if I can put JSP scriptlets in a
<jsp:attribute> or is it scriptless content only?
Originally posted by Charles Lyons:
This depends on what tag you are supplying the content to: if it's a classic tag, scripting elements are permitted. If it's a SimpleTag, then a <jsp:attribute> cannot contain a scriptlet. If it's an element you're creating using <jsp:element>, then scripting elements are permitted as content of an enclosed <jsp:attribute> since a <jsp:element> is a standard action (it isn't actually implemented as a tag handler).
The attributes are processed before the body of the tag.
Thouhg the <jsp:attribute> directly encloed in the tag, It is not exactly the body of the tag. The attributes are processed before the body of the tag. I think it is related to the rtexprvalue attribute of the <attribute> tag or <@ attribute> directive> in the tag files.
NOTE: The <mytag attr="<%= date %>" /> is illegal in a JSP document because the < character should be used only for the start of elements (instead you should use a < entity reference). You might try:
<mytag attr="<jsp:expression>date</jsp:expression>" />
But this is illegal because elements can't be placed in attribute values. The valid alternative is therefore:
I think even this can be used:
correct me if i am wrong.