I am preparing for scwcd exams. I have doubt about what is the scope of the attributes declared in the tag file? In the SCWCD 1.5 book (2nd edition), its stated in the BANG on page no. 504 that tag attributes have scope of TAG only.
In the same book, in Coffee Cram, question no 18, in answers, option F which is correct answer, says that "Each attribute declared and specified in the tag file, the container creates page-scoped attribute with the same name."
I am confused with these two conflicts. Is there any typo mistake in answers?
Yes page scoped variables will be created. This is from the JSP 2.0 spec :
For each attribute declared and specified, a page-scoped variable must be created in the page scope of the JSP Context Wrapper. The name of the variable must be the same as the declared attribute name. The value of the variable must be the value of the attribute passed in during invocation. For each attribute declared as optional and not specified, no page-scoped variable is created. If the tag accepts dynamic attributes, then the names and values of those
dynamic attributes must be exposed to the tag file as specified in Table JSP.8-2.
Vish Shukla wrote:that tag attributes have scope of TAG only
That is a different thing, those attribute values passed to the tag file by invocation of the tag file.. Yes those are tag scoped.
I think I have confused you in the previous post, It actually mean the same thing but the attributes are created in the page scope of the Tag file itself. Implementation uses in attrubute setters something like :
the "jspContext" used here is the JspContext for the given tag file. Hope it's clear now