• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

How does c:remove scope=... work?

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, my question is regarding this <c:remove> tag's functionality:
<c:set var="userStatus" value="Brillant" scope="request"/>
UserStatus is now: ${userStatus}.<br><br>
<c:remove var="userStatus"/>
After remove, userStatus is now: ${userStatus}.

Why is userStatus still removed even with the different scopes, request for the c:set and page for the c:remove? If I use application scope with c:set and c:remove with request scope, then it works properly, why?

Thanks so much,
Carmen
 
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

If you use <c:remove var="varstat" /> without specifying the scope it remove all attributes named varstat for all scopes.

If you use <c:remove var="varstat" scope=".." /> with specifying the scope it remove attribute named varstat for given scope only.

Thanks
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats right,

<c:remove var="varName" />

Works just like the pageContext.removeAttribute("varName") method, it removes the attribute with the specified name from all scopes.



<c:remove var="varName" scope="scope" />

Works just like pageContext.removeAttribute("varName",SCOPE) it removes the attribute from the specified scope.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when <c:remove> in mentioned without a scope it starts from the default scope that is page scope and then searches all the scopes one by one in the order of least restriction i.e, page, request, session, application for the variable specified.
 
I want my playground back. Here, I'll give you this tiny ad for it:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic