Richard,
I would think the same way. The data I get is not
large, so I could store it in a file.
I haven't tested by seeing whether reading from a file
or connecting from a database is faster.
Did anyone implement this before and have any idea
about performance issues talked about?
Ravi.
--- Richard Yee <[EMAIL PROTECTED]> wrote:
> Ravi,
> How much data are you talking about here? Using
> either a file or the
> session to store the data is not a very good idea.
> Using a file limits the
> scaleability and would be relatively slow.
> Maintenance of the temporary
> files also becomes an issue. Use of files is also
> problematic if server
> clusters are used b/c it ties the session to a
> particular machine. Large
> amounts of data should not be stored in the user's
> session either b/c it
> limits the scaleability again and eats up the
> server's memory.
>
> For a large # of records, I'd recommend just
> connecting to the database
> again and use the database to sort for you using the
> ORDER BY clause. The
> database is highly optimized for this purpose. An
> EJB is a great solution
> if you can use them.
>
> Regards,
>
> Richard
>
> At 10:14 AM 7/19/01 -0700, you wrote:
> >Kevin,
> >
> >Thanks a lot for gving me such useful pointers.
> >Though aware of Lists and Comparators, I didn't
> know
> >TreeMaps.
> >
> >>From my original question of sorting, the data
> needs
> >to be stored somewhere, right either in a file
> using
> >TreeMaps or in the session.
> >
> >Performance wise which would be better?
> >
> >Thanks,
> >Ravi.
> >
> >--- Kevin Baynes <[EMAIL PROTECTED]> wrote:
> >> Ravi-
> >>
> >> You need to look at the Collections API for
> storing
> >> your data. This will
> >> teach you about TreeMaps, Lists and Comparators:
> >>
> >>
>
>http://developer.java.sun.com/developer/onlineTraining/collections/Collectio
> >> n.html
> >>
>
>http://developer.java.sun.com/developer/technicalArticles/Collections/Using/
> >> index.html
> >>
> >> You will also need to understand Serialization
> and
> >> the Serializable
> >> interface:
> >>
> >>
>
>http://java.sun.com/docs/books/tutorial/essential/io/serializing.html
> >>
>
>http://java.sun.com/products/jdk/1.2/docs/guide/serialization/
> >> be sure to look at the examples and FAQ in the
> above
> >> link.
> >>
> >> 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: Wednesday, July 18, 2001 11:01 PM
> >> > To: [EMAIL PROTECTED]
> >> > Subject: Re: Sorting using servlets
> >> >
> >> >
> >> > Hi Mark,
> >> >
> >> > It would be great if you could give me an
> example
> >> > code. I did not understand what you wrote? is
> >> there
> >> > any article where I could read about that?
> >> >
> >> > I don't know what is a TreeMap. Could you
> >> enlighten
> >> > me?
> >> >
> >> > Thanks,
> >> > Ravi.
> >> >
> >> > --- Mark Galbreath <[EMAIL PROTECTED]> wrote:
> >> > > Nah...that would not be efficient. Better to
> do
> >> it
> >> > > on the server by sending
> >> > > the data into a TreeMap (implements
> SortedMap)
> >> and
> >> > > make it available to all
> >> > > clients through a serialized download.
> >> > >
> >> > > Cheers!
> >> > > Mark
> >> > >
> >> > > ----- Original Message -----
> >> > > From: "Mike Peyvandi" <[EMAIL PROTECTED]>
> >> > > Sent: Tuesday, July 17, 2001 11:39 PM
> >> > >
> >> > >
> >> > > > Another option would be an applet in the
> >> response
> >> > > to take care of sorting
> >> > > at
> >> > > > the client side. This way you can omit
> some
> >> extra
> >> > > calls to the server for
> >> > > > sorting purpose.
> >> > > >
> >> > > > Mike
> >> > > >
> >> > > >
> >> > > > -----Original Message-----
> >> > > > From: Kevin Baynes
> >> > > > Sent: Tuesday, July 17, 2001 2:43 PM
> >> > > >
> >> > > > 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: Ravi Shankar Jagarapu
> >> > > > > Sent: Tuesday, July 17, 2001 12:39 PM
> >> > > > >
> >> > > > > 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
>
=== message truncated ===
__________________________________________________
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