Q: If you do not specify a scope...
A: If you do not use the optional "scope" attribute in the tag, then the tag will only look in the page scope space....
SCJP 1.6, SCWCD 1.5
Syntax 1: Set the value of a scoped variable using attribute value
<c:set value=”value” var=”varName” [scope=”{page|request|session|application}”]/>
Syntax 2: Set the value of a scoped variable using body content
<c:set var=”varName” [scope=”{page|request|session|application}”]>
body content
</c:set>
Syntax 3: Set a property of a target object using attribute value
<c:set value=”value” target=”target” property=”propertyName”/>
Syntax 4: Set a property of a target object using body content
<c:set target=”target” property=”propertyName”>
body content
</c:set>
SCJP 1.6, SCWCD 1.5
Session Scoped Variable 2
Page Scoped Variable:
Search and display the least scoped variable: 2
Session Scoped Variable 2
Page Scoped Variable: 1
Search and display the least scoped variable: 1
If you do not use the optional "scope" attribute in the tag, then the tag will only look in the page scope space
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
The container is following the specs here.
The session scoped attribute's value has not changed to 2. ${sessionScope.twee} would still display 1.
Q: If I don’t specify a scope, does that
mean it will find attributes that are ONLY
within page scope, or does it do a search
beginning with page scope?
A: If you don’t use the optional “scope”
attribute in the tag, then the tag will only
look in the page scope space. Sorry, you
will just have to know exactly which scope
you are dealing with.
SCJP 1.6, SCWCD 1.5
Aj Deschanel wrote:Thanks a lot everybody.
Looks like whatever they say in the book is related to c:set with var attribute.
It makes 100% sense since with target it uses EL and EL knows to search all scopes, as Abimaran already mentioned.
Q: If I don’t specify a scope, does that
mean it will find attributes that are ONLY
within page scope, or does it do a search
beginning with page scope?
A: If you don’t use the optional “scope”
attribute in the tag, then the tag will only
look in the page scope space. Sorry, you
will just have to know exactly which scope
you are dealing with.
If the value evaluates to null, the variable will be removed. If there is an existng attribute with the same name, the attribute will be removed.
If you don't specify a scope, it starts looking at page,then request etc.
OCP-Java 6 (100%),OCWCD-JavaEE 5
a. If the var is not found AND the scope is not specified, it will search only in the page scope and create an attribute if it does not previously exist.
If the value is null AND the scope is not specified, the attribute would be searched in all the scopes (page,request,session and so on) and removed wherever it is found first.
4.3 <c:set>
... removed ...
If value is null
- Syntax 1: the scoped variable defined by var and scope is removed.
+ If attribute scope is specified, the scoped variable is removed according to the semantics of PageContext.removeAttribute(varName, scope).
+ Otherwise, the scoped variable is removed according to the semantics of PageContext.removeAttribute(varName).
public abstract void removeAttribute(String name)
Remove the object reference associated with the given name from all scopes. Does nothing if there is no such object.
OCP-Java 6 (100%),OCWCD-JavaEE 5