tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Goodenough <david.goodeno...@btconnect.com>
Subject Re: Problem in IO taglib
Date Sun, 01 Aug 2004 14:56:52 GMT
Posted as bug  30427 .

On Sunday 01 August 2004 12:56, David Goodenough wrote:
> 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).

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Mime
View raw message