File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Scope of attribute in Tag file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Scope of attribute in Tag file" Watch "Scope of attribute in Tag file" New topic
Author

Scope of attribute in Tag file

Vish Shukla
Ranch Hand

Joined: Oct 12, 2008
Posts: 111
Hello all,

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?

Please reply as soon as possible.

Thanks & Regards,
Vishal S Shukla (SCJP 93%, SCWCD 94%, SCBCD 100%)
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3816

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.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Vish Shukla
Ranch Hand

Joined: Oct 12, 2008
Posts: 111
Vijitha,

Thanks for quick reply. But I still didn't get exactly what's the difference between these two attributes. In both the cases, its referring to attributes passed in tag file when invoking the tag.

Can you please elaborate in depth?

Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3816

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Scope of attribute in Tag file
 
Similar Threads
SCWCD questions
doubt (question) on Tag File attribute scopes (Q18 p557)
page 448 Default scope of c:remove
Attributes in Tag Files: 'Tag' scope or Page scope?
HFSJ errata confusion