• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFS page 567, question 18

 
Jessica White
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
F is listed as a correct answer, it says:

"For each attribute declared and specified in a Tag File, the container creates a page-scoped attribute with the same name."

However, on page 494, bottom block, it says:

"All tag attributes have TAG scope."

Kinda confused here. Is the attribute in a tag file, page scoped or tag scoped? And by page scoped, does it mean the calling page, or the included tag file(page)?

Thx.
 
Jayanthi Mani
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am also getting a little confused here. Are tag attributes tag-scoped or page-scoped? Any input would be really appreciated.

Thanks,
Jayanthi.
 
Guido Schoepp
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer F (question 18 on pg. 567) refers to the implementation of the tag file. The spec says for tag files: "For each invocation to the tag, the JSP Context Wrapper must present a clean page scope containing no initial elements." This page scope is referring to the tag file itself.

The "bang" box on page 494 refers to the usage of the tag in another JSP. Look at the sample in the book:
<myTags:header subTitle="..."/>
${subTitle} //This won't work! The attribute is out of scope

Guido
 
Dale Seng
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've concluded that this question is a bit of a cheap shot.

There are really two page scopes when you are talking about "the Tag File model". You have the original jsp context (from the calling page), and the new one the container has to create inside the tag. The spec says:

"For each attribute declared and specified, a page-scoped variable must be created in the page scope of the JSP Context Wrapper. For each attribute declared and specified, a page-scoped variable must be created
in the page scope of the JSP Context Wrapper."

Which almost exactly matches answer "F", but it's the "almost" that's the problem. In the spec, just above the quote, they spend a whole lot of time explaining that this is not the JSP Context Wrapper from the originating page. "F" doesn't indicate at all which page scope it's talking about.

The question would be answerable if instead of "the container creates a page scope attribute", it said "witin the tag's jsp context, the container creates a page scoped attribute", but even that would be hard!

The only good thing is that it makes one read the spec! I'm convinced that that's why this question is designed this way!

--Dale--
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic