aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes JSTL: remove object from scope Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "JSTL: remove object from scope" Watch "JSTL: remove object from scope" New topic
Author

JSTL: remove object from scope

Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
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,


cmbhatt
khushhal yadav
Ranch Hand

Joined: Jun 20, 2007
Posts: 242

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


rgrds,
Khushhal
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
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,
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
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 ]

Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
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 ]
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
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

Joined: Feb 28, 2007
Posts: 1707
Thank you Michael,

I appreciate you!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL: remove object from scope