Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

page 448 jstl doubt

 
Sami Sayeed
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Guido Schoepp
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Kapil Dev
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sami Sayeed
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kapil,

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

cheers
Sami
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic