• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

About the "target" attribute of c:set

 
Ranch Hand
Posts: 229
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Edmund Yong
Ranch Hand
Posts: 229
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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" />
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



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.
 
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic