On 04/10/18 00:16, Daniel Becroft wrote:
> Hi,
>
> We are setting up Tomcat 8 to use a CGI program (.exe, proprietary) to
> generate and return various JSON responses. This all works fine when the
> response is a HTTP 200. But, when an HTTP error is returned (HTTP 4xx),
> Tomcat is generating the HTML page instead.
>
> We have the same setup working under IIS, and we had to configure the
> following option there to stop IIS doing the same thing:
>
> <httpErrors existingResponse="Passthrough">
>
> Is there an existing option somewhere in Tomcat that will do the same thing
> (ie keep the CGI response intact even if it's a HTTP error)? I can't seem
> to find one.
No, but I think you can work-around it. If the response has been
committed (i.e. written to the network), Tomcat can't replace the error
page. Try adding a filter that calls ServletResponse.flushBuffer()
immediately after the CGI servlet has finished.
Something like (untested):
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
chain.doFilter(request,response);
response.flushBuffer();
}
> ---
> Daniel Becroft
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]