You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by William Kaufman <WK...@viquity.com> on 2001/05/07 22:16:57 UTC

RE: send response to browser and continue processing in servlet.s ervice()

> I tried SevletResponse.getOutputStream().flush() which will 
> send all output
> to the browser. However, the browser's indicator keep on spinning.

Is that a bad thing?

That is, when you're off working on something else, is the page finished or
isn't it?  

If it is finished, you can close the output stream, and do the work in
another thread.  If it isn't finished (i.e., if the work you're doing has to
return to the browser's page), then the browser _should_ seem busy, because
it's waiting on more data.

(Any other solution to this, including launching more browser windows or
refreshing the page constantly for extra data, will be solved with
HTML/HTTP, and won't be specific to Tomcat, to servlets, or even to any Java
code.  You can try looking around HTML web sites, like html.about.com or
www.webdeveloper.com .)

                                                            -- Bill K.


> -----Original Message-----
> From: Wai-Yip Tung [mailto:wtung@cisco.com]
> Sent: Monday, May 07, 2001 12:20 PM
> To: tomcat-user@jakarta.apache.org
> Subject: send response to browser and continue processing in
> servlet.service()
> 
> 
> Is there a way to send the response to browser and then continue some
> lengthy processing in the Servlet.service() method? I'm using 
> IE and I tried
> these scenarios.
> 
> I tried SevletResponse.flushBuffer() which seems to have not effect.
> I tried SevletResponse.getOutputStream().flush() which will 
> send all output
> to the browser. However, the browser's indicator keep on spinning.
> I tried SevletResponse.getOutputStream().close() also but it 
> also seems to
> have no effect.
> 
> The indicator won't stop until I exit Servlet.service().
> 
> Because of my design, I can't just start a thread and exit. 
> Is there anyway
> I can tell Tomcat I want to remain in Servlet.service() for a 
> while. All
> output has been send and please close the socket?
> 
> Thanks for any help!
> 
> Wai-yip
> 
> 
> 
>