Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
649 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This is about my first experience with programming Arduino.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

789 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