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

clarification with c:set

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic