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

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
vdevaruppalaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
raj3060Connect With a Mentor Commented:
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
 
DrWarezzCommented:
Yeah, send us what you've got so far please. :)
Thanks,
[r.D]
0
 
elfragaCommented:
send the code
0
 
raj3060Commented:
My suggestion works well for sorting the resultset. I beleive that I should get credit.
-raj
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.