• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL: remove object from scope  RSS feed

 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have four objects in four different scopes
[page,request,session,application].

And I use:
<c:remove var="popy"/>

In the absence of the scope attribute it removes the objects from all the
four scopes.

If it is required to remove the object from the session
scope won't <c:remove var="popy"/> be correct answer too, because it
starts from page and goes on goes on, finding and removing objects of that
name from the scopes?

Please confirm this!

Thanks,
 
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No Chandra

Because the requirement is to remove it from session.
Not from all the scopes.

Just imagine of the havoc, it can create in a running application.
If by mistake
instead of writing <c:remove var="popy" scope="session"/>
you write <c:remove var="popy"/>

Objects in the other scopes might being used somewhere else in the application.

So it always better to be specific.

And in exam, I think it will depend on the number of options to be choosen.

Regards,
Khushhal
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks khushhal,

Yeah it is was I was looking for! It would depend on how many options
we have to choose, but we should be very specific. Alright!


Thanks,
 
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chandra,

You are absolutely correct.

Given options
1. <c:remove var="poppy"/>
2. <c:remove var="poppy" scope=session/>

if (asked to select one which will delete poppy from session only) {
then choose 2.
}
else{
if (asked to select two from following which can delete poppy from session) then choose 1,2.
}
[ August 14, 2007: Message edited by: Srinivasan thoyyeti ]
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah Srinivasan,

That would be right way to handle with that sort of question.

Your wise description made it more clear!

Thanks,
[ August 14, 2007: Message edited by: Chandra Bhatt ]
 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chandra, thank you for your post that pointed out the in the absence of a scope attribute in the <c:remove> tag, the scope is all scopes. On page 448 pf HFSJ it says that the default scope is page. I missed the correction in the errata of the book

{448} 2nd handwritten comment;
The scope is optional, and like always - page is the default scope.
should be:
The scope is optional, and when not specified the attribute is removed from all scopes.



In appreciation of your post, I have written a JSP that points out what you wrote. Here it is




Once again, thanks
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Michael,

I appreciate you!

 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!