You invoke a Tag File with a tag, and tags can have attributes. So it’s only natural that the Tag File developer might want to invoke the tag with attributes... attributes that get sent to the Tag File.
Invoking the tag from the JSP
Before (using <jsp:param> to set a request parameter)
<jsp:include page="Header.jsp"> <jsp:param name="subTitle" value="We take the sting out of SOAP." /> </jsp:include>
After (using a Tag with an attribute)
<myTags:Header subTitle="We take the String out of SOAP" />
Using the attribute in the Tag File
All tag attributes have TAG scope. That’s right, just the tag. Once the tag is closed, the tag attributes go out of scope!
You have to be clear about these—the <jsp:include> <jsp:param> value goes in as a request parameter. That’s not the same as a request-scoped attribute, remember. The name/value pair for the <jsp:param> looks to the web-app as though it came in with a form submission. That’s one of the reasons we DON’T like using it—the value you meant to pass ONLY to the included file, ends up visible to any component in the web app that is a part of this request (such as servlets or JSPs to which the request is forwarded).
But the nice, clean thing about tag attributes for Tag Files is that they’re scoped to the tag itself. Just be sure you know the implications. This will NOT work: ...