This is the first I've seen of this message, either it didn't get delievered
the first time or it got lost in the spam that is my mailbox.  That said,
what you are trying to do *should* work, I'm not sure what's going on with
it.  The elements do sit in a hashtable, but the keys are added to a vector
and retrieved out of the hashtable in the order they were inserted into the
vector so the order should be maintained.  This the first post I've seen in
several years mentioning that the element tree was not being maintained in
the appriorate order, I'll see if I can reproduce the problem here, and post
a solution if I'm able to reprodcue it.

-stephan

----- Original Message -----
From: "David Tonhofer, m-plify S.A." <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, September 01, 2002 1:14 PM
Subject: REPOST: Bug or Dumbass attack?


> Not having received any answer so far, I dare to repost....
>
> Hello,
>
> Just a question regarding weird behaviour of an ECS code
> snippet. I was wondering whether this is *supposed to happen*
> because I haven't understood how to use ECS properly or
> something. Here goes:
>
> 1) I get text from an InputStream and want to write it to
>    HTML output as <tt>foo</tt> inside a servlet.
>
> 2) I thought this might do it (ok, so I *DO* have a more
>    efficient loop, this for illustration purposes..copy
>    character by character, replace newlines or carriage
>    returns by <BR>, replaces space by &nbsp;):
>
> Document doc = new Document();
> doc.setDoctype(new Doctype.Html40Transitional());
> TT tt = new TT();
> char[] buffer = new char[BUFFERSIZE];
> int actuallyRead;
> do {
> actuallyRead = isr.read(buffer);
> int startOff = 0;
> for (int i = 0; i < actuallyRead; i++) {
> if (buffer[i] == '\n' || buffer[i] == '\r') {
> tt.addElement(new BR());
> } else if (buffer[i] == ' ') {
> tt.addElement(Entities.NBSP);
> } else {
> tt.addElement(new String(buffer,i,1));
> }
> }
> } while (actuallyRead == buffer.length);
> doc.appendBody(tt);
> doc.output(res.getWriter());
>
> 3) When I run that though, the output is horribly mangled
>    as if the structure underlying TT was messing things up
>    (something to do with the Hashtable implementation?)
>    A sample output:
>
>    C noToller3inforeat ona-  - - --- ----------------------------
>    Total irount of memory in VM  - :v89791 KByte
>    Amoent  f  emory stile available: 9897 KBy e
>    Amount  f0 emo  eused      -     p79894 KByte C n truct time
>
>    This changes between 'updates'...
>
> 4) For comparison, just piping the text to the ouput page
>    (after having given it content type text/plain) gives:
>
>    Controller information
>    ---------------------------------------
>    Total amount of memory in VM    : 89791 KByte
>    Amount of memory still available: 6818 KByte
>    Amount of memory used           : 82973 KByte
>    Construct time                  : 2002.08.28 10:36:52:188
(@1030523812188
>
>
> So...am I sadly mistaken or is something going on?
>
> Best regards,
>
> -- David Tonhofer
> m-plify S.A.
>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to