tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick>
Subject Re: Odd behavior of Number/String conversion??
Date Tue, 08 Mar 2005 15:11:02 GMT
Rahul P Akolkar wrote the following on 3/7/2005 6:51 PM:

> <c:set var='theField' value="${metaProps[fn:replace('field.*.type', '*', 
> fieldNum)]}"/>
> Conceptually, a fn:join is a better fit here, but I'm not too keen on 
> creating arrays in JSPs ;-) Finally, if temporary variables is what you're 
> after, 'theField' would be the next in line, although readability has its 
> own benefits.

Thanks Rahul for the info. I'm wondering which would have less overhead 
behind the scenes... using the replace like you have it above or storing 
  what I want to replace in a temp var? The reason I ask is this 
operation will have to actually be repeated several times within an 
outer loop. I looked at fn:join also but that seems like even a bit more 
work since I'd have to push each item into a String[] first.

So, the two options seem like...

<c:set var="tempVal" value="field.${fieldNum}.type"/>
<c:set var="theField" value="${metaProps[tempVal]}"/>


<c:set var='theField' value="${metaProps[fn:replace('field.*.type', '*',

Behind the scenes I'm sure some String concatenation is taking place 
with the first set of the tempVal so I'm not sure how efficient that is 
anyway. The replace code looks a lot cleaner, so I'm leaning towards 
that solution.

Thanks again,


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message