Forums Register Login

page 448 jstl doubt

+Pie Number of slices to send: Send
Hi,

the page 448 describes how to use c:remove tag,

it states that the scope if not mentioned in the <c:remove var="blah"/>
resolves to page scope.

I have a program as follows
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<c:set var="user" scope="session" value="cowboy"/>

<c:set var="dog" value="tommy"/>
${dog}
${user}
<c:remove var="user"/>// the c:remove tag removes the user variable created under session scope even without me mentioning the scope..

<a href="testset.jsp">clcik to test</a>
+Pie Number of slices to send: Send
 

Originally posted by Sami Sayeed:

the page 448 describes how to use c:remove tag,
it states that the scope if not mentioned in the <c:remove var="blah"/> resolves to page scope.
[...]
<c:remove var="user"/>// the c:remove tag removes the user variable created under session scope even without me mentioning the scope...



You're right - the book is wrong.

The JSTL specs say: "If attribute scope is not specified, the scoped variable is removed according to the semantics of PageContext.removeAttribute(varName)."

And the API docs for JspContext.removeAttribut(String) say: "Remove the object reference associated with the given name from all scopes."

Guido
+Pie Number of slices to send: Send
Guido Schoepp,

did you then mean that <c:remove var="user"/> will not remove the session scoped variable "user". Will this remove a request scope variable "user" if it did exist in the request scope?
Could you please explain?
Thanks.
+Pie Number of slices to send: Send
Hi Kapil,

The c:remove var="user"/>
recursively removes all the varaibles of the name "user" in all scopes

cheers
Sami
I'm gonna teach you a lesson! Start by looking at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 867 times.
Similar Threads
How does c:remove scope=... work?
a JSTL question in Whizlabs Exam Simulator
assign expression language value to a string
JSTL: remove object from scope
doubt in c:remove
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 01:08:19.