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

page 448 Default scope of c:remove

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) If i have userStatus attribute in page and request scope.
Will <c:remove var="userStatus"/> remove page scope attribute or both the attribute's.

What is the default scope in the <c:remove>

Can we remove a request attribute(userStatus) with this <c:remove scope="request">userStatus</c:remove>

2) Page 567 Q18
Option F. For each attribute declared and specified in a Tag file,the container creates
a page-scoped attribute with the same name.

Is it Correct.

In Page 494,It is said All tag attributes have TAG scope.

Is Tag scope and Page scope same.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) If you specify the scope as being "request", only the attribute in the request will be removed. If you don't specify any scope, attributes in all scopes will be removed. (see PageContext.removeAttribute(varName))
 
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

...attributes in all scopes will be remove....



no.... this is what theapi says -

removeAttribute
public abstract void removeAttribute(java.lang.String name)Remove the object reference associated with the given name, look in all scopes in the scope order.

Parameters:
name - The name of the object to remove


so, once a attribute is removed from some scope, the next scope in the scope order will not be searched for.

correct me if i am worng
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

so, once a attribute is removed from some scope, the next scope in the scope order will not be searched for


Where did you read this in the API ?
I've got this (I'm talking about PageContext.removeAttribute, which is actually JspContext.removeAttribute) :

public abstract void removeAttribute(java.lang.String name)
Remove the object reference associated with the given name from all scopes.
Does nothing if there is no such object.
Parameters:
name - The name of the object to remove.
Throws:
NullPointerException - if the name is null
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello there,
Don't confuse your self so much.
Please refer to HFSJ.
<c:remove var="num" />
scope attribute is optional so if not mentioned the attribute is searched for in the following scopes in order
1) page
2) request
3) session
4) application

so if an attribute named "num" is there in page scope it will not go further.
so if you specifically want to remove the attribute in request scope then mention as :
<c:remove var="num" scope="request" />

Best Regards,
Pallavi
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pallavi, I hope you're not talking about page 448, which is in the errata.

{448} 2nd handwritten comment;
The scope is optional, and like always - page is the default scope.
should be:
The scope is optional, and when not specified the attribute is removed from all scopes.
 
Satish Saravanan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Satou, I conformed with the spec.
so it is as follows,If there is no scope,then the attributes in all the scopes will be removed.
public abstract void removeAttribute(java.lang.String name)
Remove the object reference associated with the given name from all scopes.
Does nothing if there is no such object.
Parameters:
name - The name of the object to remove.tish
Throws:
NullPointerException - if the name is null
Thanks
satish
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<c:remove scope="request">userStatus</c:remove>

is this valid declaration..???

 
Your buns are mine! But you can have this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic