IntelliJ Java IDE
The moose likes JSP and the fly likes problem regarding JSTL remove tag Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "problem regarding JSTL remove tag" Watch "problem regarding JSTL remove tag" New topic
Author

problem regarding JSTL remove tag

Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 128

Hi
I'v made a code for demo of remove tag of JSTL.

Output of the above code is-
userstatus is : Brilliant
userstatus is now : Brilliant

The output which I expect is-
userstatus is : Brilliant
userstatus is now : not available

In this JSP page, previously scope of var is set as application and im removing is from page scope. So shouldn't it be removed from the current page? Why is has not been removed?
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50691

If you put something in one box, and try to remove it from a different box, does it disappear from the first box? Of course not.

If you want to remove it from app scope, you need to specify app scope on the remove action. It's not in page scope, so you can't remove it from somewhere where it does not exist.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 128

but if something is in application scope, that means that field is visible in whole application. So, shouldn't it in page scope also? and in this code, im trying to remove it from that particular page.
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50691

No, that's no the way it works.

Things in app scope aren't copied to page scope. The page sees the page, request, session and app scopes, and hence sees all the scoped variables in those scopes.

Think of them as four separate boxes that the page can see. You can't remove an item from a box that that item is not in.
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 128

Ah..i was taking it as a hierarchy of scopes. Now its clear to me...thanks
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50691

Well, it is a hierarchy of scopes. But your mistake was in thinking that app scoped wear shared with a page by somehow copying the values into page scope. Not so.

When a scoped variable is referenced, first page scope is searched, and if the variable is not found there, request scope is searched, then session scope, then app scope.
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 128

Ok...thanks Bear Bibeault
now one last question. if these scopes make a hierarchy, than we should consider these scopes like separate boxes or like small box page contained inside a bigger box request which is contained inside bigger box session again which is inside the bigger one application?
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50691

The scopes do not contain each other. The hierarchy defines the search order for references.
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 128

Got it. thankyou
 
IntelliJ Java IDE
 
subject: problem regarding JSTL remove tag
 
Threads others viewed
How does c:remove scope=... work?
jstl <c:import url= /> not working
JSTL c:remove
JSTL library poblem
cset doubt??
MyEclipse, The Clear Choice