Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

c:set using var

 
Naresh Chaurasia
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<c:set> using var can create new request-scoped attribute. My question is that does request-scoped attribute means that the scope of the reques is request and we cannot specify other scopes for the attribute. Please correct me if i am wrong
 
Srinivasan Rengan
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An attribute can be set at any of the four levels(request,session,application or page) using <c:set>. It is not restricted to the request scope alone.

Srini
 
Rizwan Mohammad
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use scope attribute to set the scope. default one is page scope.
 
Nicky Eng
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by N Chaurasia:
<c:set> using var can create new request-scoped attribute. My question is that does request-scoped attribute means that the scope of the reques is request and we cannot specify other scopes for the attribute. Please correct me if i am wrong


are you trying to say something like this:

<c:set var="cart" scope="request" scope="session" />

where 2 scope inside the c:set ??

i dont think this can work. It can either :

<c:set var="cart" scope="request" />
OR
<c:set var="cart" scope="session" />
OR
<c:set var="cart" scope="page" />
OR
<c:set var="cart" scope="application" />

am i correct?
 
Rizwan Mohammad
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
scope is one of the attribute of set tag.
<c:set var="id" value="100" scope="session">
is equivalent to session.setAttribute("id", "100");
if you dont give scope attribute then it is equivalent to
pageContent.setAttribute("id","100");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic