Re: REPOST: Bug or Dumbass attack?

2002-09-03 Thread David Tonhofer, m-plify S.A.

Hello,

Here is a Servlet that produces text from the Jungle Book,
with increasing text length.

It seems that the problem only manifests itself if the
number of elements is large. I should have said in my first
posting that the output was a few pages, not a few lines.

Best regards,

-- David Tonhofer

--On Monday, September 02, 2002 8:27 PM +0200 David Tonhofer, m-plify 
S.A. [EMAIL PROTECTED] wrote:

 Ok, thanks. I will try to reproduce ASAP...will try to find
 an hour tomorrow. But I'm currently positively *wrestling*
 with some other code issues 8-( ... (aren't we all?)

 --On Monday, September 02, 2002 11:30 AM -0500 Stephan Nagy
 [EMAIL PROTECTED] wrote:

 I cannot reproduce this problem, here is my test case.

[snip]

import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.util.*;

import org.apache.ecs.html.TT;
import org.apache.ecs.html.Input;
import org.apache.ecs.html.H3;
import org.apache.ecs.Document;
import org.apache.ecs.Entities;
import org.apache.ecs.html.BR;
import org.apache.ecs.Doctype;
import org.apache.ecs.html.Form;

public class ECSTestCase extends javax.servlet.http.HttpServlet {

public void doGet(javax.servlet.http.HttpServletRequest request, 
javax.servlet.http.HttpServletResponse response) throws 
javax.servlet.ServletException, java.io.IOException {
performTask(request, response);
}


public void doPost(javax.servlet.http.HttpServletRequest request, 
javax.servlet.http.HttpServletResponse response) throws 
javax.servlet.ServletException, java.io.IOException {
performTask(request, response);
}

private void performTask(javax.servlet.http.HttpServletRequest request, 
javax.servlet.http.HttpServletResponse response) throws 
javax.servlet.ServletException, java.io.IOException {
final String DATA =
It was seven o'clock of a very warm evening in the Seeonee hills\n
+ when Father Wolf woke up from his day's rest, scratched himself,\n
+ yawned, and spread out his paws one after the other to get rid of\n
+ the sleepy feeling in their tips.  Mother Wolf lay with her big\n
+ gray nose dropped across her four tumbling, squealing cubs, and\n
+ the moon shone into the mouth of the cave where they all lived.\n
+ \Augrh!\ said Father Wolf.  \It is time to hunt again.\  He 
was\n
+ going to spring down hill when a little shadow with a bushy tail\n
+ crossed the threshold and whined: \Good luck go with you, O 
Chief\n
+ of the Wolves.  And good luck and strong white teeth go with 
noble\n
+ children that they may never forget the hungry in this world.\\n
+ \n
+ It was the jackal--Tabaqui, the Dish-licker--and the\n
+ wolves of India despise Tabaqui because he runs about making\n
+ mischief, and telling tales, and eating rags and pieces of 
leather\n
+ from the village rubbish-heaps.  But they are afraid of him too,\n
+ because Tabaqui, more than anyone else in the jungle, is apt to 
go\n
+ mad, and then he forgets that he was ever afraid of anyone, and\n
+ runs through the forest biting everything in his way.  Even the\n
+ tiger runs and hides when little Tabaqui goes mad, for madness is\n
+ the most disgraceful thing that can overtake a wild creature.  We\n
+ call it hydrophobia, but they call it dewanee--the madness--\n
+ and run.\n
+ \n
+ \Enter, then, and look,\ said Father Wolf stiffly, \but there\n
+ is no food here.\\n
+ \n
+ \For a wolf, no,\ said Tabaqui, \but for so mean a person as\n
+ myself a dry bone is a good feast.  Who are we, the Gidur-log 
[the\n
+ jackal people], to pick and choose?\  He scuttled to the back of\n
+ the cave, where he found the bone of a buck with some meat on it,\n
+ and sat cracking the end merrily.\n
+ \n
+ \All thanks for this good meal,\ he said, licking his lips.\n
+ \How beautiful are the noble children!  How large are their 
eyes!\n
+ And so young too!  Indeed, indeed, I might have remembered that\n
+ the children of kings are men from the beginning.\\n
+ \n
+ Now, Tabaqui knew as well as anyone else that there is nothing\n
+ so unlucky as to compliment children to their faces.  It pleased\n
+ him to see Mother and Father Wolf look uncomfortable.\n
+ \n
+ Tabaqui sat still, rejoicing in the mischief that he had made,\n
+ and then he said spitefully:\n
+ \n
 

Re: REPOST: Bug or Dumbass attack?

2002-09-02 Thread Stephan Nagy

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 ttfoo/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]




Re: REPOST: Bug or Dumbass attack?

2002-09-02 Thread Stephan Nagy

I cannot reproduce this problem, here is my test case.

import org.apache.ecs.html.TT;
import org.apache.ecs.html.BR;
import org.apache.ecs.Document;
import org.apache.ecs.Doctype;
import org.apache.ecs.Entities;
import java.io.ByteArrayInputStream;

public class test {

public static void main(String[] args)

{

Document doc = new Document();

doc.setDoctype(new Doctype.Html40Transitional());

TT tt = new TT();

long mem = Runtime.getRuntime().freeMemory();

long total = Runtime.getRuntime().totalMemory();

String f = Total amount of memory in VM : +total+\n+Amount of memory
still available : +mem+\n+Amount of memory used =
+(total-mem)+\n+Construct time : +System.currentTimeMillis()+\n;

ByteArrayInputStream bais = new ByteArrayInputStream(f.getBytes());

byte[] buffer = new byte[1024];

try

{

while(true)

{

int read = bais.read(buffer);

if(read == -1)

break;

for(int x = 0 ; x  read; x++)

{

if(f.charAt(x) =='\n')

tt.addElement(new BR());

else if(f.charAt(x) == ' ')

tt.addElement(Entities.NBSP);

//tt.addElement(nbsp;);

else

// tt.addElement(String.valueOf(f.charAt(x)));

tt.addElement(new String(buffer,x,1));

}

}

doc.appendBody(tt);

doc.output(System.out);

}

catch(java.io.IOException ioe)

{

ioe.printStackTrace();

}

}

}



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




Re: REPOST: Bug or Dumbass attack?

2002-09-02 Thread David Tonhofer, m-plify S.A.

Ok, thanks. I will try to reproduce ASAP...will try to find
an hour tomorrow. But I'm currently positively *wrestling*
with some other code issues 8-( ... (aren't we all?)

--On Monday, September 02, 2002 11:30 AM -0500 Stephan Nagy 
[EMAIL PROTECTED] wrote:

 I cannot reproduce this problem, here is my test case.

 import org.apache.ecs.html.TT;
 import org.apache.ecs.html.BR;
 import org.apache.ecs.Document;
 import org.apache.ecs.Doctype;
 import org.apache.ecs.Entities;
 import java.io.ByteArrayInputStream;

 public class test {

 public static void main(String[] args)

 {

 Document doc = new Document();

 doc.setDoctype(new Doctype.Html40Transitional());

 TT tt = new TT();

 long mem = Runtime.getRuntime().freeMemory();

 long total = Runtime.getRuntime().totalMemory();

 String f = Total amount of memory in VM : +total+\n+Amount of memory
 still available : +mem+\n+Amount of memory used =
 +(total-mem)+\n+Construct time : +System.currentTimeMillis()+\n;

 ByteArrayInputStream bais = new ByteArrayInputStream(f.getBytes());

 byte[] buffer = new byte[1024];

 try

 {

 while(true)

 {

 int read = bais.read(buffer);

 if(read == -1)

 break;

 for(int x = 0 ; x  read; x++)

 {

 if(f.charAt(x) =='\n')

 tt.addElement(new BR());

 else if(f.charAt(x) == ' ')

 tt.addElement(Entities.NBSP);

 //tt.addElement(nbsp;);

 else

 // tt.addElement(String.valueOf(f.charAt(x)));

 tt.addElement(new String(buffer,x,1));

 }

 }

 doc.appendBody(tt);

 doc.output(System.out);

 }

 catch(java.io.IOException ioe)

 {

 ioe.printStackTrace();

 }

 }

 }



 --
 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]




Bug or Dumbass attack?

2002-08-28 Thread David Tonhofer, m-plify S.A.

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 ttfoo/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]