• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

<c:set var

 
Aditi Kamra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a doubt about c:set with the "var" version (<c:set var="name" value=""/>

If the value evaluates to null , and the scope is not mentioned , I understood from HFSJ that it will start looking in all the scopes starting from page scope, so if this var is present in more than one scope, will it remove it from all scopes(like c:remove does when scope is not mentioned) or just the one it encounters first ?

Might be a silly doubt but can somebody please clear this out ..


Thanks in Advance

Regards,
Aditi
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the JSTL spec

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).


So the attribute will be removed from all the scopes. The following is from the java documentation of PageContext.removeAttribute(String)

Remove the object reference associated with the given name from all scopes. Does nothing if there is no such object.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic