Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: JSTL: getting a map's keys Date: Mon, 19 Mar 2012 12:57:42 -0700 (PDT) Organization: http://groups.google.com Lines: 55 Message-ID: <3861256.1341.1332187062277.JavaMail.geo-discussion-forums@pbbpk10> References: <9spbepF1baU1@mid.individual.net> NNTP-Posting-Host: 69.28.149.29 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1332187187 14811 127.0.0.1 (19 Mar 2012 19:59:47 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 19 Mar 2012 19:59:47 +0000 (UTC) In-Reply-To: <9spbepF1baU1@mid.individual.net> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Received-Bytes: 2655 Xref: csiph.com comp.lang.java.programmer:13054 On Monday, March 19, 2012 11:15:52 AM UTC-7, Chris Riesbeck wrote: > Can anyone help me figure out why the following is happening, or further > experiments I can run? (I have workarounds but I'd like to know what I'm > misunderstanding.) > > Given: > - SimTable, a subclass of HashTable [sic] that defines getKeys() to call If you mean 'java.util.Hashtable', that's a rather obsolete class. You should stick with 'java.util.HashMap'. > keyset() Joshua Bloch recommends to prefer composition over inheritance. > - a session variable "data" which is a HashTable with "rates" set to > an instance of a SimTable If "rates" is set to an instance of a 'HashTable', or whatever, is 'data' then a 'Map>'? > Why does ${rates.keys} generate nothing in these lines of JSP? How about you follow the advice here: http://sscce.org/ and then maybe we can help you. It would make it easier for you to answer the questions I'm asking. I think perhaps you're overthinking the session vars. Why can't your 'rates' Map go in there directly? > > > > rates: ${rates}

> > > jstl: ${rates.keys}

> > > jsp: <%= ((edu.northwestern.ils.simulator.SimTable) > pageContext.findAttribute("rates")).getKeys() %>

> > Here's the generated HTML output: > > > rates: {Bill=100.0, Fred=75.0, Jane=75.0, Mary=50.0, Sam=75.0, > Sarah=150.0}

> > > jstl:

> > > jsp: [Bill, Fred, Jane, Mary, Sam, Sarah]

Your example code is fragmented and incomplete. Give us something we can work with, please. -- Lew