1

サーブレットで HTTP ストリーミングを使用しようとしています。ローカルで orion をサーブレット コンテナーとして使用し、正常に動作しますが、JRUN 4.0 を実行するテスト サーバーでは、出力ストリームで flush() を呼び出しても出力がバッファーされます。出力がバッファリングされている理由と、それを止めるためにできることについて何か考えはありますか?

OutputStream os = servletResponse.getOutputStream();

while (true)
{
    //attempt to write to output before doing anything else. If browser has disconnected, an IOException will be thrown so nothing else will be done
    os.write(".".getBytes());
    os.flush();

    String response = getData();
    os.write(response.getBytes());
    os.flush();
    try
    {
        Thread.sleep(1000);
    }
    catch (InterruptedException e)
    {

    }
}
4

0 に答える 0