This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
and made a java object with setter and getter methods for name and des to store the query results. Then I have stored all java objects in a Hashmap and sending this hashmap to jsp from servlet. Now at jsp I am displaying this hashmap in table format.I want the results to be sorted according to say like "desc". How can I achieve this in java?I dont want to modify query. Thanks.
Preeti, I don't follow why you are using a HashMap. The value is the objects you built and the key is what?
In any case, you have two choices for sorting: 1) Add a compare to method and have your object implement comparable. Then call Collections.sort() on the values in the HashMap. 2) Write your own comparator and pass it to Collections.sort