| Author |
Question on c:set
|
Santana Iyer
Ranch Hand
Joined: Jun 13, 2005
Posts: 335
|
|
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
Joined: May 14, 2007
Posts: 244
|
|
<c:set> has the 'scope' attribute to specify the scope of your attribute. Maybe you are confusing it with the standard action <jsp:setProperty>?
|
SCJP<br />SCWCD 1.4 Upgrade (Remember: me stupid)<br />SCWCD 1.4<br /><a href="http://jcp.org/aboutJava/communityprocess/final/jsr220/index.html" target="_blank" rel="nofollow">SCBCD 5.0</a><br /><a href="http://www.enthuware.com" target="_blank" rel="nofollow">SCBCD 5.0 mock exam</a> <br /> <br />SCEA 5 Part1: Preparing...
|
 |
Hendy Setyo Mulyo
Ranch Hand
Joined: Dec 01, 2004
Posts: 219
|
|
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?
|
Hendy Setyo Mulyo
SCJP 1.4 (95%), SCWCD 1.4 (94%)
|
 |
Mirko Bonasorte
Ranch Hand
Joined: May 14, 2007
Posts: 244
|
|
|
Simply, <c:set> sets the variable at the specified scope. :-)
|
 |
Santana Iyer
Ranch Hand
Joined: Jun 13, 2005
Posts: 335
|
|
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
Joined: Nov 24, 2005
Posts: 14672
|
|
|
http://www.coderanch.com/t/174554/java-Web-Component-SCWCD/certification/set-tag
|
[My Blog]
All roads lead to JavaRanch
|
 |
 |
|
|
subject: Question on c:set
|
|
|