• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on c:set

 
Santana Iyer
Ranch Hand
Posts: 335
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per my understanding if we use var without scope than container searches in all four scopes and if it cant find in any of four scope container makes new on in page scope.


So I stored attribute in session scope and in c:set action I put var="nameofattributeinsessionscope" value="newvalue"

but session attribute is not modified instead new attribute of same name created at page scope.

So is it that first para is wrong and if scope not specified it defaults to page and only that will be serached if not found create attribute in page scope without searching through request, session, application.
 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<c:set> has the 'scope' attribute to specify the scope of your attribute.
Maybe you are confusing it with the standard action <jsp:setProperty>?
 
Hendy Setyo Mulyo
Ranch Hand
Posts: 219
Firefox Browser Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mirko,

I still confused, if the scope attribute is not specified, will it search in page scope, then continued request scope, session scope and application scope?
Is this mechanism also applicable for c:remove?
 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simply, <c:set> sets the variable at the specified scope. :-)
 
Santana Iyer
Ranch Hand
Posts: 335
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If you read HFSJ page 447 Q2 it says if you don't specify scope attribute in tag than container will search scopes in order in which you expect page, request, session, application.
If container can not find in any of four scope new attribute created in page scope.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic