Hi,
To keep this thread in topic, must tell you not to forget
to send the data back using an ServletOutputStream.. ;-)
Of course there are many simpler solutions:
int j = 1;
1. Take only one hashtable, no vectors, no arrays.
(For excesive portability will reffer it as an "Dictionary").
2.1 for each row you retrieve store the data with two keys:
- one being the "alphabetic" key.
- put the same data with a new Integer(j++) as key.
So you will be able to retrieve the same data from Hashtable
either by String or numeric lookup (by row number!).
2.2 Or use only Integer keys, if you just need to retrieve the
rows in the same order the resultset gave them
2.3 for the same purpose as (2.2) may use just an existing FIFO.
3. Check container sizes - resultsets may get BIG,
specially when you query demographic data...
Bye,
Cezar
P.S. this should be awarded as
"The most known and debated demographic servlet"
On Tue, 23 Mar 1999, Steven Lewis wrote:
> Yes - the hashtable hashes the order
> Best approach to this
> 1) Store in a vector
> 2) When you are done say
> MyDataType[] SortedData = new MyDataType[MyVector.size()];
> MyVector.copyInto(SortedData);
> now store in the Hashtable and dump the vector if you need a hashtable
> for fast lookup
>
> At 10:33 AM 3/23/99 -0500, you wrote:
> >I have a servlet that pulls demographic data rowsets (sorted alphabetically
> >by last name) from a database. I then place information into a Hashtable()
> >using last name as the key and vectors as the stored objects. When I pull
> >out an Enumeration of the hashtable keys and then print them out they are
> >not in the same order that I put them into the hashtable! I lose the alpha
> >sorting from the original rowsets.
> >
> >Is there something in Enumeration that causes the keys to come out in any
> >old order? Is there something in Hashtable? Is there a simple way to fix
> >this?
> >
> >Darren
> >
> >___________________________________________________________________________
> >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
>
> ==============================================================
> LordJoe - Java Training and Consulting
> http://www.LordJoe.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
>
Cezar Totth email: [EMAIL PROTECTED]
Fax: (401) 220 33 95
Genesys Software Romania Phone: (401) 638 49 44
Stefan Furtuna 169, sect.6
cod 77171, Bucharest
Romania
___________________________________________________________________________
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