• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

page 448 jstl doubt

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Let's go to the waterfront with this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic