Ravi-

You could make the database call, save the results into a temporary
structure, put it where you can access it on the next call. You can do this
by either saving it to the Session, or by serializing it to a file and
accessing it by some key that you save to the Session.

You could use Arrays, Vectors, Lists, or a custom built object.

I suggest you use Lists and Comparators for storage and sorting.

Kevin Baynes
Seagull Software



> -----Original Message-----
> From: A mailing list for discussion about Sun Microsystem's Java Servlet
> API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Ravi
> Shankar Jagarapu
> Sent: Tuesday, July 17, 2001 12:39 PM
> To: [EMAIL PROTECTED]
> Subject: Sorting using servlets
>
>
> 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

___________________________________________________________________________
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

Reply via email to