Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

page 448 Default scope of c:remove

 
Satish Saravanan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • 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.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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))
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • 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 Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
 
Pallavi Roy
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • 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 Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
thilina sampath
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<c:remove scope="request">userStatus</c:remove>

is this valid declaration..???

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic