This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt in c:set tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt in c:set tag" Watch "Doubt in c:set tag" New topic
Author

Doubt in c:set tag

raja ram
Ranch Hand

Joined: Mar 02, 2008
Posts: 169
Hi,

In HFSJ it is said that when in <c:set> tag when the value is null or blank then it will not add the variable in to the scope instead if the variable is already present then it will search for it and remove it from that scope based on this information when i say

<c:set var="g" value="12" />
value of variable g is ${g} it will print 12 that is correct

when i say value of unknow variable is ${asd} where asd is a undeclared variable it prints blank(nothing) it is also correct because it cant find asd variable in any of the scope

based on the statements given in the HFSJ i tried this line

<c:set var="g" value="null" />
value of variable g after making it as null is ${g}

now value attribute is having null so the variable g has to be removed from the scope so the out put should be same as the that of variable asd but this is not happening i am getting value of variable g after making it as null is null that means <c:set> is not removing variable g from scope and it is taking "null" has a value itself

is there any mistakes in what i have done.

also <c:set target="${cm.map}" var="k" value="12" scope="request" > even this tag works fine notice i have both target and var attribute both at the same time.

all the other JSTL tags like <c:if>,<c:when>,<c:forEach> are working fine.


Thanks
Garlapati Ravi
Ranch Hand

Joined: Mar 05, 2008
Posts: 168

basic java question to you,
which one do you pick up to assign null to a string variable:
String st = null;
(or)
String st = "null";

Hope you got what i mean. You should have tried like this:
or


Ravi Kumar
SCWCD 5 - 89%, SCJP 1.4 - 90%
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16


What is it ?


[My Blog]
All roads lead to JavaRanch
Garlapati Ravi
Ranch Hand

Joined: Mar 05, 2008
Posts: 168
Good catch Christophe, i was bit doubt on that statement , i never tried it, that's why i have given another option to try
raja ram
Ranch Hand

Joined: Mar 02, 2008
Posts: 169
Hi,

Thanks got it i understood.

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in c:set tag
 
Similar Threads
c:set var question
JSTL (c:set)
Tag file variable question
JSTL: remove object from scope
doubt in JSTL set tag