You can use XML and XSL...I did not work on it..But i know you can do it
very easily...
You can write sorting logic in XSL...
-raj-
-----Original Message-----
From: Peter Huber [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 18, 2001 2:07 PM
To: [EMAIL PROTECTED]
Subject: Re: Sorting using servlets
Hi take a look at java.util.Arrays method (since 1.2)
public static void sort(Object[] a,
int fromIndex,
int toIndex,
Comparator c)
For your purpose you must store each output line into an array of objects.
Each
of these objects
represents a row of your output. Each row-objects has individual data
members
which
represent the columns of your output.
Then build a comparator for each column-sort. The comparator 'knows' which
of
the rows data-members it's supposed to concider for sorting and then let the
sort method do the rest!
Peter
Ravi Shankar Jagarapu wrote:
> Hi all,
>
> I am retrieving data from the database with several
> fields, like for example first name, last name,
> join date, salary.
>
> This data is displayed by the servlet.
> Now my requirement, is that, if anyone clicks on first
> name, the data should now be displayed sorted on that
> field and if on salary then sorted on salary.
>
> I don't want to connect to the database each time and
> retrieve the same information just to sort the data
> which is already available to me.
>
> Can anyone suggest a better method? Would be great if
> you could give an example code.
>
> Many Thanks,
> Ravi.
>
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
--
*** Bitte beachten Sie unsere neuen Mail- und Internet-Adressen ***
*** Please notice the new mail- and internet-address ***
--
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html