File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Question on c:set Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Question on c:set" Watch "Question on c:set" New topic
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: 14687
    
  16

http://www.coderanch.com/t/174554/java-Web-Component-SCWCD/certification/set-tag


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on c:set