Solved

How to use Alphabetical sorting for values getting from resultset and display the values in a drop down on a jsp page

Posted on 2004-09-15
6
638 Views
Last Modified: 2008-03-03
Hi ,

I have three things to do

1) collect the String values coming from a ResultSet on a specific column name.
2) store  the values into a java collection and sort the collection in Alphabetical order.
3) send the sorted collection to a jsp to be displayed in a drop down.

I have tried using the java.util.List to collect the values and used the Collections.sort()
and i get the the values unsorted and with padding like "[" and " ] " for the all the elements stored in the
list.

I probably can send u guys snippets of code if it helps..

Thanks
Deva
0
Comment
Question by:vdevaruppala
  • 2
6 Comments
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12069367
Yeah, send us what you've got so far please. :)
Thanks,
[r.D]
0
 
LVL 1

Expert Comment

by:elfraga
ID: 12070349
send the code
0
 
LVL 11

Accepted Solution

by:
raj3060 earned 500 total points
ID: 12071206
You can have SQL to do that for you, that is best way to do it. e.g

select * from names orderby lname;

Query like this will bring your data in sorted form like you want.
Another way is like you tried to it. Depends what you are retreiving and how you are storing it. Use arraylist, or vector and then sort it with collection class.
We can tell more if you tell us more and post snippet.
--Raj
0
 
LVL 11

Expert Comment

by:raj3060
ID: 12281228
My suggestion works well for sorting the resultset. I beleive that I should get credit.
-raj
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question