• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

get hashmapvalues of arraylist

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
iam getting result set as hashmap and storing them in a an arraylist and returning that arraylist to the method callers.
When i applied iterator on that returned arraylist with itr.hasnext () iam getting key and values also
BUT for some reasons i just want to get only values from arraylist
could some one suggest me please

and if some one have an idea to get resultset object arraylist values. bcz when i did that iam getting 2nd row data repeated infinately.
 
Bartender
Posts: 2662
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to our 'Java in General' forum.
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

When i applied iterator on that returned arraylist with itr.hasnext () iam getting key and values also..


So don't add the keys in to the ArrayList.
Not sure what to suggest without looking at your code though.
Please UseRealWords when posting here, because instead bcz...
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

kumar amara wrote:iam getting result set as hashmap and storing them in a an arraylist and returning that arraylist to the method callers.



can you ellaborate ? here what do you mean by *result set * ?
 
kumar amara
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

thsi is how i get the rresultset into hashmap and then storing it in an arraylist
when i iterate with this arraylist iam getting hashkey,datavalue
but i want to get only the values

there is no hashmap method to get only values without key


and in arraylist i don't find useful info regarding how to get only value without key
so any kindly helpme so that i can display that values in my table rows to display to the user
i also tried to get the resultset to arraylist of arraylist and when i usse get twise which is neeeded to get arraylist in arraylist it gives me irrelavent data.
if any one having idea

with arraylist of arraylist then it will be fine



hope i will get any one success way
i googled but no way to get the exact info!
 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you need the column names as well or only the values? How are you suppose to set the values to be passed to the caller?

there is no hashmap method to get only values without key


There's a Map.values() method.

and in arraylist i don't find useful info regarding how to get only value without key


ArrayList is not a Map so doesn't know anything about key-value pairs.

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

kumar amara wrote:
the rresultset into hashmap and then storing it in an arraylist
when i iterate with this arraylist iam getting hashkey,datavalue



when you iterate the list, you *should* get the Map . then use value() as vijitha suggested or entrySet()
 
kumar amara
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
let s iam getting that arraylist into my servlet with
so how could i get a map.value able to call from arraylist


like this any worked example will be useful,
and I Have a Great doubt on why arraylist not Able to SEND to JSP page successfuly
what are the prerequisites to do this.

ANY exact idea on arraylist to jsp successfully dispatched one there
or should i display from servlet only through printwriter
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

kumar amara wrote: any worked example will be useful,


please google


kumar amara wrote:
ANY exact idea on arraylist to jsp successfully dispatched one there


Use one of the scope , something like this *request.setAttribute("objName","Show Some Effort")*

kumar amara wrote:
or should i display from servlet only through printwriter


No. use out[JspWriter is an implicit Object in jsp] . but I suggest you to go for EL which is a good practice

hth
 
kumar amara
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is it confirmed that arraylist or any resultset in servlet should go to jsp successfully only if EL is used in JSP.
and jsp writer is to be used where in servlet or in JSP,



please google



thank you !
 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

kumar amara wrote:is it confirmed that arraylist or any resultset in servlet should go to jsp successfully only if EL is used in JSP.


Not sure what you mean by "go to jsp..". But you use JSTL, EL, Standard/Custom actions to maniplate data in JSPs these days, not Scriptlets/Scriplet expressions etc..
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic