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).
Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
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:
<mytag>
<jsp:attribute name="attr"><jsp:expression>date</jsp:expression></jsp:attribute>
</mytag>
Regards,<br />Jigar Gosar (SCJP 1.4)<br />visit: <a href="http://jigar.org/blog" target="_blank" rel="nofollow">http://jigar.org/blog</a>
I think even this can be used:
correct me if i am wrong.
Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
What a show! What atmosphere! What fun! What a tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|