• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

c:remove

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Author
Posts: 836
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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!)
 
Aleksander Zielinski
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 836
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic