The Artima Developer Community
Sponsored Link

Java Answers Forum
why i can't get the hashtable value printed?

2 replies on 1 page. Most recent reply: Sep 20, 2006 3:09 AM by anuj singhal

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
meir meir

Posts: 1
Nickname: umen
Registered: Aug, 2006

why i can't get the hashtable value printed? Posted: Aug 30, 2006 8:41 AM
Reply to this message Reply
Advertisement
hello all
i have simple hashtable i can get the keys but i cant get the values
why?
<%String event = request.getParameter("eventFrom") ;event = (event != null ? event : "");if(event.equalsIgnoreCase("result")){ java.util.Hashtable myHashtbl = new java.util.Hashtable(request.getParameterMap()); if(!myHashtbl.isEmpty()){ Enumeration keysEnum = myHashtbl.keys(); while(keysEnum.hasMoreElements()){ String keyName = (String)keysEnum.nextElement(); String keyValue = (String)myHashtbl.get(keyName.toString()); out.println("KeyName: "+keyName+"<br>"); out.println("ValueName: "+keyValue+"<br>"); } } }else{ }%><html><body><form name="test" id="test" action="<%= request.getRequestURI() %>" method="get" ><input type="hidden" name="eventFrom" value="result" ><input type="hidden" name="<%="this_is_key_1" %>" value="<%= "4444444" %>" /><input type="hidden" name="<%="this_is_key_2" %>" value="<%= "2424"%>" /><input type="submit" name="okButton" id="okButton" class="button" style="width:80px;" value="Submit" /></form></body></html>


joe smith

Posts: 21
Nickname: jetbrains
Registered: Jan, 2006

Re: why i can't get the hashtable value printed? Posted: Aug 31, 2006 11:59 PM
Reply to this message Reply
It's hard to see your code because of disorder.
See this java hashmap tutorial,hope it help
http://www.developerzone.biz/index.php?option=com_content&task=view&id=90&Itemid=36

anuj singhal

Posts: 4
Nickname: anujs
Registered: Sep, 2006

Re: why i can't get the hashtable value printed? Posted: Sep 20, 2006 3:09 AM
Reply to this message Reply
Following code snippet is causing you trouble
String keyValue = (String)myHashtbl.get(keyName.toString());

Instead,
do it this way:-
String keyValue = (String)myHashtbl.get(keyName);

Flat View: This topic has 2 replies on 1 page
Topic: hi Previous Topic   Next Topic Topic: help regarding Visual basic

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use