You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Adam Ratica <ad...@cardinalcommerce.com> on 2001/04/04 17:37:04 UTC

Inputstream blocking during read, when there is nothing to read

If I send an empty get request to my servlet, get the inputstream, and do a
read it will block forever.
(eg: just call the servlet from IE or Netscape it just hangs).

InputStream in = servletRequest.getInputStream();
byte[] buffer = new byte[bufferSize];
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
int read = 0;
do {
	System.out.println("getBody1");
      read = in.read(buffer);
      System.out.println("getBody2");
      if(read>=0) { byteStream.write(buffer, 0, read); }
} while (read >= 0);

"getBody2" is never printed.
In Tomcat 3.2 I had the same problem
In Tomcat 3.3 the read would return, but -1 would never be returned, so it
would loop forever.


This servlet works fine on iplanet, and vqserver.

Also the size returned is -1, so I can't just slurp it into an array.

Thank you,
Adam Ratica
Software Architect
CardinalCommerce, Inc.
6119 Heisley Road    Mentor, OH 44060
440-352-8444 x138    440-352-1646 Fax
adamr@cardinalcommerce.com