I think I have found a problem in the IO taglib.  

I have a site where I use JSP with JSTL and the IO taglibs to provide a
web frount end to a servlet which takes XML requests and delivers
XML responses (this is used by some embedded systems as well as
the web UI).

Every now and then I get a null response back from the servlet when
using the IO taglib.  The embedded systems never hit this problem.
The log at the Servlet indicates that a response was sent, and ethereal
concures.

Originally the servlet only accepted https requests, even from the
web UI, and this is where I hit this problem first.   I changed the
servlet so that it would accept http requests from localhost and 
the problem diminished but did not go away.

The problem - I think - is in the org.apache.taglibs.io.PipiHelper
class, in the pipe routine.  It currently reads:-

            while (true) {
                int size = input.read( buffer );
                if ( size <= 0 ) {
                    return;
                }
                output.write( buffer, 0, size );

The problem is that size can be zero, especially for https
sessions when the stream is not at end of file.  The only
real end of file is when size == -1.

The code should read:-

            while (true) { 
                int size = input.read( buffer ); 
                if ( size < 0 ) { 
                    return; 
                } 
                else if( size == 0)  {
                        Thread.sleep( 1);
                }
                else {
                         output.write( buffer, 0, size ); 
                }

I am not sure whether the Thread sleep is necessary, but it does
give the scheduler a chance when the request is to a local source
in the same process (i.e. to a Tomcat servlet).

I am currently trying to build the IO taglibs with this fix to confirm
that it fixes the problem, but I am having difficulties largely to do with
constructing a build environment.

David

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

Reply via email to