hi!
first of all  i think this is will be a problem on any tomcat
version.............
the stream will wait indefinitely........
so a better thing to do would be to look for a timeout condition........
say wait for some specified amount of time ...and then exit.......
looks like there is no other go bcoz the length specified is more so the
reader/stream will wait.
time it out.....;)

for Example    in  the usual message say of which the first 10 bytes
describe the length ...

BufferedReader  buffReader
  =   new BufferedReader( new InputStreamReader(
 _urlConn2.getInputStream() ) );
  while( true )
  {
       char[] charArray1 = new char[10];
       buffReader.read( charArray1 , 0 ,10  );
       String length = new String( charArray1 );
       int lengthInt = 0;
       try{
            lengthInt   = new Integer( length ).intValue();
       }
       catch( Exception e)
       {
            System.out.println(" Error " + e );
            e.printStackTrace();
       }
       char[] charArray2  = new char[lengthInt];
       buffReader.read( charArray2 );
       System.out.println( " Read bytes");
       System.out.println( new String( charArray2 ) );
       // for continuos reading..... trial.only..
        if( 1==2)
        break;
  }

 now in this if we have a timeStamp say....... the the timeStamp1
corresponding to time where we got the first 10 bytes and timeStamp2
corresponding to the time before we do the reading of the actual content

say...
     timeStamp1    =    System.getCurrentTimeMillis();

for ( int tempCount=0; tempCount<lenghtInt ; tempCount++ )
{
        timeStamp2    =    System.getCurrentTimeMillis();
        if( timeStamp2 - timeStamp1 < 2000)//say 2 secs
         {
               charArray[tempCount]    =    buffReader.read();
                timeStamp1    =    System.getCurrentTimeMillis();
          }
}

this might work....
sorry for this long story if anyone got pained..
beginners attacks r usaully damaging ;) n boring....


cheers
subzero
> Hi Friends,
>
> I am facing a problem when I use Tomcat 4.0 as the servlet container.
> I receive an http request (which has an invalid content length - ie- the
content length specified is more than the actual data). When I read the
request through a reader, it blocks indefinitely waiting for more data to
arrive while there is actually none.
>
> Tomcat does not even kill this thread and it just blocks. The problem here
is that I use a singleton object to read the request. So this singleton gets
blocked while reading and all other requests are also blocked.
>
> I don't want to change the implementation of the singleton to per thread
based object since it involves memory issues.
> Is there any way by which we can ensure that requests with invalid content
lengths are not blocked while reading ? Does any non blockigncall exist for
reading the request ?
>
> Thanks
> Amit
>
>
___________________________________________________________________________
> 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
>

___________________________________________________________________________
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

Reply via email to