• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Carmen Brianick
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • 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
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • 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
 
Liyaquat Ali
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • 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.
 
Swapna Sharma
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic