On Fri, Oct 5, 2018 at 3:12 AM Christopher Schultz < ch...@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > Daniel, > > On 10/3/18 19: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. > > See Mark's response for the "answer" to this; I had another question. > > HTTP 4xx responses are usually telling the client that their request > was bad for some reason, and generally the response entity (the page > returned) is not relevant. > > What kinds of responses are you returning for these errors? Or are you > trying to make sure that the response is still JSON even if an error > occurs? > > - -chris > Thanks Chris. We are using the response to return information about what was wrong with the request, and how they might need to fix it. For example: { "errorCode" : "400" "errorMessages": [ "The customer cannot be terminated with an outstanding invoice." ] } This is the format that our existing consumers are already receiving the responses in, so we can't change that. Cheers, Daniel B.