• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

c:set var

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Reference HFSJ Pg 445

"If the value of the object is null, the attribute is removed. (If scope is not specified it will start looking at page, request, and so on)"

Now if it does find an attribute at page level, i thought only the page level attribute is removed.

It came as a surprise to me that the attribute at all levels is removed.



Output
Print set values
>com.example.bean.MyBean@8fbecf<
>request<
>session<
>application<
Print new values
><
><
><
><

Is this a bug or it is supposed to work this way?
Using Tomcat 5.5.23
 
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

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


And if you look at PageContext.removeAttribute(varName) : Remove the object reference associated with the given name from all scopes. Does nothing if there is no such object.

So if you don't specify the scope, and the value is null, then the variable will be removed from all scopes.
 
swarna dasa
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!!! Should have looked at the API docs
Thanks though!!!
 
swarna dasa
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An Add-on

In the above jsp if we have a c:set without value, then only the pagescope is affected


Output is

><
>request<
>session<
>application<

if value is not provided then is the value considered to be an empty string as against null?
reply
    Bookmark Topic Watch Topic
  • New Topic