> 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. > > Old code: > > > > final int PARTIAL_HITS = 25; > > > > for (int i = 0; i < hits.length(); i++) { > > > > /** Insert into table omitted */ > > > > if (i == PARTIAL_HITS) { > > // Intermittant redirect, not acted on until doPost returns > > out.sendRedirect(resultUrl); > > return; // why not terminate the method call here? > > > } > > } > > > > if (!out.isCommitted()) { > > // Final redirect > > out.sendRedirect(resultUrl); > > } > > > > New code: > > > > final int PARTIAL_HITS = 25; > > > > for (int i = 0; i < hits.length(); i++) { > > > > /** Insert into table omitted */ > > > > if (i == PARTIAL_HITS) { > > // Intermittant redirect, acted on immediately > > out.setHeader("Location", resultUrl); > > out.setStatus(303); > > out.setContentLength(0); > > out.flushBuffer(); > > } > > } > > > > if (!out.isCommitted()) { > > // Final redirect (if case less than PARTIAL_HITS found) > > out.sendRedirect(resultUrl); > > } > > _______________________________________________________________ Tore Eriksson [tore.eriksson at po.rd.taisho.co.jp] --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]