tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leon Rosenberg" <>
Subject Re: Committing sendRedirect()
Date Thu, 23 Oct 2008 05:52:58 GMT
On Thu, Oct 23, 2008 at 2:12 AM, Tore Eriksson
<> wrote:
>> Tore Eriksson wrote:
>> > Hello everybody,
>> >
>> > As I found a solution to my problem, I thought I would share it in case
>> > someone else comes up against the same issue. The reason for the client
>> > not acting on the redirect is that sendRedirect does not send any
>> > Content-length header, and the client will then wait for an eventual
>> > Content body until the servlet finishes. This could be avoided if the
>> > sendRedirect would include "Content-length: 0" in its HTTP headers. I
>> > solved my problem by manually constructing the redirect on the
>> > HttpServletResponse object ('out' below).
>> Why don't you just insert "return;" after the first redirect was called?
>> p
> Becuse the doPost code have to keep on running and process more results after
> the redirect.

And thats why it doesn't work :-)

The "proper" or more common way of achieving your task is to start the
search in another thread/executor, monitor its progress, and return
from the initial thread/request as soon as the progress is sufficient,
letting the search thread finish his job in background.

The problem with your solution is, that you are thinking you can make
both at once: return from processing and continue processing. I can
imagine that even your "hack" may work under special circumstances it
is not guaranteed to work in another container, another version of
same container, proxied or behind http.
Imagine if you are running in a wrapped request, as long as the thread
will continue to execute, nothing will be send to client. Of course
you can hack everything, but sparing a threeliner for a new thread
just isn't worth it.


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message