Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Chris Riesbeck Newsgroups: comp.lang.java.programmer Subject: Re: JSTL: getting a map's keys Date: Wed, 21 Mar 2012 13:09:05 -0500 Lines: 32 Message-ID: <9sujq2Foc1U1@mid.individual.net> References: <9spbepF1baU1@mid.individual.net> <9srshfFjo5U1@mid.individual.net> <9sruffF39oU1@mid.individual.net> <14359232.4616.1332266714833.JavaMail.geo-discussion-forums@pbcr5> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net p02bgTAanjrbbXskTcX7DALV/RNr36WjNbK1mc2n1I1Ircf5c3 Cancel-Lock: sha1:WT+bpv5M/YQ1bQop43pABD6RhdU= User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20120312 Thunderbird/11.0 In-Reply-To: <14359232.4616.1332266714833.JavaMail.geo-discussion-forums@pbcr5> Xref: csiph.com comp.lang.java.programmer:13102 On 3/20/2012 1:05 PM, Lew wrote: > Chris Riesbeck wrote: >> http://docs.oracle.com/javaee/5/api/javax/servlet/jsp/JspApplicationContext.html >> >> So the Map interpretation will always override the Bean interpretation. > > Now that your main question is answered, a couple of comments are in order. > > - Don't have scriptlet in your JSPs. I never do. That was in the original JSP just to show that getKeys() was functioning and returning a non-empty result > - If you had *composed* a 'Map' into a custom class rather than > inheriting 'Map', you would not have had the problem. Your custom > class would have been resolved by the bean resolver. - This in turn > would make for a better design overall. Instead of your view artifact > (the JSP) caring about the implementation details of the map and its > set of keys, you'd have a controller call like 'getKeys()' or > whatever that would cleanly separate the logic of how you get them > from presentation concerns. Using delegation (my preference also) doesn't support the JSP EL form ${rates["Bill"]}. If I had a custom class, I'd need a custom tag or custom EL resolver to make that work. The original goal was to get the JSTL away from knowing about Map's, in particular about entry.key and entry.value.