File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes <c:set var Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "<c:set var" Watch "<c:set var" New topic
Author

<c:set var

Aditi Kamra
Greenhorn

Joined: Aug 25, 2009
Posts: 7
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

Joined: Aug 03, 2008
Posts: 9280
    
  17

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.


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: <c:set var
 
Similar Threads
page 448 jstl doubt
c:remove does not remove from all scopes
doubt in c:remove
c:remove
Confusion about "scope" attribute