Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #13054

Re: JSTL: getting a map's keys

From Lew <lewbloch@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: JSTL: getting a map's keys
Date 2012-03-19 12:57 -0700
Organization http://groups.google.com
Message-ID <3861256.1341.1332187062277.JavaMail.geo-discussion-forums@pbbpk10> (permalink)
References <9spbepF1baU1@mid.individual.net>

Show all headers | View raw


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<String,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?

>    <c:set var="rates" value='${data["rates"]}'/>
> 
>    
> rates: ${rates}</p>
> 
>    
> jstl: ${rates.keys}</p>
> 
>    
> jsp: <%= ((edu.northwestern.ils.simulator.SimTable) 
> pageContext.findAttribute("rates")).getKeys() %></p>
> 
> 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}</p>
> 
>    
> jstl: </p>
> 
>    
> jsp: [Bill, Fred, Jane, Mary, Sam, Sarah]</p>

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

-- 
Lew

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

JSTL: getting a map's keys Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-03-19 13:15 -0500
  Re: JSTL: getting a map's keys Lew <lewbloch@gmail.com> - 2012-03-19 12:57 -0700
  Re: JSTL: getting a map's keys Tim Slattery <Slattery_T@bls.gov> - 2012-03-19 16:08 -0400
    Re: JSTL: getting a map's keys Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-03-19 16:06 -0500
      Re: JSTL: getting a map's keys Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-03-19 16:39 -0500
    Re: JSTL: getting a map's keys markspace <-@.> - 2012-03-19 15:27 -0700
  Re: JSTL: getting a map's keys Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-03-19 16:59 -0700
    Re: JSTL: getting a map's keys Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-03-20 12:19 -0500
      Re: JSTL: getting a map's keys Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-03-20 12:52 -0500
        Re: JSTL: getting a map's keys Lew <lewbloch@gmail.com> - 2012-03-20 11:05 -0700
          Re: JSTL: getting a map's keys Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-03-21 13:09 -0500
            Re: JSTL: getting a map's keys Lew <noone@lewscanon.com> - 2012-03-22 07:51 -0700
              Re: JSTL: getting a map's keys Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-03-22 12:53 -0500
                Re: JSTL: getting a map's keys Lew <lewbloch@gmail.com> - 2012-03-22 13:23 -0700
                Re: JSTL: getting a map's keys Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-03-23 12:23 -0500
                Re: JSTL: getting a map's keys Lew <noone@lewscanon.com> - 2012-03-23 13:50 -0700
                Re: JSTL: getting a map's keys Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-03-26 14:10 -0500
        Re: JSTL: getting a map's keys Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-03-20 11:28 -0700
        Re: JSTL: getting a map's keys markspace <-@.> - 2012-03-20 11:29 -0700
          Re: JSTL: getting a map's keys Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-03-20 12:10 -0700

csiph-web