aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes clarification with c:set Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "clarification with c:set" Watch "clarification with c:set" New topic
Author

clarification with c:set

A. Aka
Ranch Hand

Joined: Sep 08, 2012
Posts: 47
Hi,

I am reading head first (2nd edition)and I am confused.
for c:set :

if the value is null, the attribute named by var will be removed by starting looking at page, request, session if the scope is not mentioned

but if the value is not null, the default scope is page

right ?

page 455 (bang) and 457(key point and gotchas with c:set)
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1678
    
  25

Hi Aka,

if the value is null, the attribute named by var will be removed by starting looking at page, request, session if the scope is not mentioned
but if the value is not null, the default scope is page


Correct, just have a look at the specs jstl 2.2:
4.3 <c:set>
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>

Syntax 5: Set a deferred value
<c:set var="varName" value="deferred-value"/>

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, there is no way to differentiate between syntax 1 and syntax 5. The scoped variable is removed according to the semantics of PageContext.removeAttribute(varName), and the variable is removed from the VariableMapper as well.


Regards,
Frits
 
wood burning stoves
 
subject: clarification with c:set