• 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

Doubt in c:set tag

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

What is it ?
 
Garlapati Ravi
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks got it i understood.

Thanks
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic