File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

c:set var

 
swarna dasa
Ranch Hand
Posts: 108
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!!! Should have looked at the API docs
Thanks though!!!
 
swarna dasa
Ranch Hand
Posts: 108
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic