aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes About the 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 "About the "target" attribute of c:set" Watch "About the "target" attribute of c:set" New topic
Author

About the "target" attribute of c:set

Edmund Yong
Ranch Hand

Joined: Nov 16, 2003
Posts: 164
In page 446 of HFSJ, it says that the "target" is not for the attribute name of the bean or map, but for the actual attribute object.

I am not sure what it really means, because in page 486 Q4, the "target" is used as an attribute name without any problem.


SCJP 1.2, SCWCD 1.4
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
Hi,
what exactly it means it in <c:set> tag target is used to set the value of map or bean. so the target value should be the actual object..
Le me explain with example how target should be used...
<% Map map = createMap();%>
<c:set target="<%=map%>" ....>
the value of target should evaluate to actual map object..

You should not use that in the following way...
<%
// This can very well go into servlet also.
Map map = createMap();
request.setAttribute("map", map);
%>
<c:set target="map" ...../>
this is wrong.. because target is evaluating to string or attribute name and it is not evaluating to actual map..
bottom line, is always you need to assign target value using expression.
Hope, I made sense.

Originally posted by Edmund Yong:
In page 446 of HFSJ, it says that the "target" is not for the attribute name of the bean or map, but for the actual attribute object.

I am not sure what it really means, because in page 486 Q4, the "target" is used as an attribute name without any problem.


Rizwan
SCJA, SCJP, SCWCD, SCBCD, SCDJWS.
Edmund Yong
Ranch Hand

Joined: Nov 16, 2003
Posts: 164
You should not use that in the following way...
<%
// This can very well go into servlet also.
Map map = createMap();
request.setAttribute("map", map);
%>
<c:set target="map" ...../>
this is wrong.. because target is evaluating to string or attribute name and it is not evaluating to actual map..
bottom line, is always you need to assign target value using expression.

What's wrong with that? In Q4 of the chapter, it's doing this way, isn't it?

So I can do (assuming that there is a key called "key", and you want to set a value called "val"):

<c:set target="requestScope.map" property="key" value="val" />
M Rama
Ranch Hand

Joined: Mar 04, 2005
Posts: 91


What's wrong with that? In Q4 of the chapter, it's doing this way, isn't it?

So I can do (assuming that there is a key called "key", and you want to set a value called "val"):

<c:set target="requestScope.map" property="key" value="val" />


I think the code should be:



instead which will be the EL for the the object.That is what the Q4 in the same chapter does.
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

I think, it should be

<c:set target="${requestScope.map}" property="key" value="val" />

or

<c:set target="${map}" property="key" value="val" />


Thanks


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
 
 
subject: About the "target" attribute of c:set