Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieve Values From Hashtable

 
naro pad
Ranch Hand
Posts: 58
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I know this is very simple but unfortunately I can't do it. My problem is that I want to retrieve values from a Hashtable. I have this:


How can I make a loop while the Hashtable has elements to get the value?

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<c:forEach> will loop over a Map without difficulty. Just be aware that the iteration items will be instances of Map.Entry.
 
naro pad
Ranch Hand
Posts: 58
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have try to do it by this way:

but I have debug it and saw that lsAssement when is created although I have only 2 keys in hashtable is create a table of size 10 showing me the 2 keys at positions 1 and 2 of the table, 0 position is empty and then 'Ass_id' is getting the second key value instead of the first one.
Why is that?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are doing this in a JSP, why the Java rather than JSTL and EL?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic