aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes c:remove Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "c:remove" Watch "c:remove" New topic
Author

c:remove

Aleksander Zielinski
Ranch Hand

Joined: Nov 11, 2005
Posts: 127
According to HFSJ, <c:remove>'s default page is scope, so I wasn't expecting what I got. Consider these two snippets:



It will remove test just from the page scope as expected.



In this case it will remove var "test" from all the scopes, but the default value for scope is supposed to be page scope. Is there inconsistency, or am I missing something?
Charles Lyons
Author
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
According to HFSJ, <c:remove>'s default page is scope, so I wasn't expecting what I got.


This is incorrect - the default semantics of <c:remove> are to remove the attribute using PageContext.removeAttribute(String), which removes the named attribute from all scopes in which it appears.

The test functionality you are receiving is correct (and good for you for actually trying out these examples, something I always advocate!)


Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / Amazon Amazon UK )
Aleksander Zielinski
Ranch Hand

Joined: Nov 11, 2005
Posts: 127
Charles you rock! Always when you give an answer you also give an explanation and justification. If I weren't going to pass the exam next month, I'd buy your book for sure!

As a side note, in SCWCD Study Guide by David Bridgewater there's also said that default value for <c:remove>'s scope attribute is page scope.
Charles Lyons
Author
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
Thanks for your kind words...

Always when you give an answer you also give an explanation and justification.

That's something I try to encourage: think about why something works the way it does and you'll have a better understanding of how things happen... Then passing the exam (and being a better programmer) follows quickly because all the facts fit into place. For example, if you know <c:remove /> uses the JspContext.removeAttribute(String) method, then providing you remember the behaviour of that method (which you have to anyway for the exam), then you'll be fine. Try to memorise too much and you're bound to forget something! Bald facts mean very little (which is why I'm pleased to find you're actually deploying applications and trying your own examples, a skill which many exam candidates fail to see the importance of).

As a side note, in SCWCD Study Guide by David Bridgewater there's also said that default value for <c:remove>'s scope attribute is page scope.

It's an easy mistake to make, as in nearly all the cases in JSTL, if no 'scope' attribute is provided, the default is 'page' (you won't often go wrong by assuming this if in doubt). This is made worse in print by publishers' deadlines!
[ April 16, 2006: Message edited by: Charles Lyons ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: c:remove