tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier (tomcat)>
Subject Re: httpd 2.2 +mod-jk1.2.37+ tomcat 7.0.28 (debian package)
Date Thu, 22 Oct 2015 09:20:50 GMT
On 21.10.2015 19:47, André Warnier (tomcat) wrote:
> On 20.10.2015 00:13, J Lopez wrote:
>> Hi all,
>>    is it possible to filter 404 application errors taking into account
>> content-type beside http return code in jk configuration.
>>    I need to difference between application is not deployed/executing (http
>> 404 content-type html) and application running and returning a 404 json
>> response (content-type json)
>>    I have put mod-jk in debug mode and content-type is showed in logs. I
>> have not seen in documentation if a fail_on_status can be combined with
>> content-type returned.
> [...]
> I have not seen this in the documentation either, and it does not look like this feature
> is available.
> But if I understand correctly, you have 2 cases of 404 :
> 1) if the application is for Tomcat "not there" (meaning for example it is not deployed
> that particular moment), then Tomcat itself returns a 404.
> 2) if the application is there and working, in some cases it returns a 404 itself.
> And for some reason, you want to distinguish these 2 cases.
> (It would help to know why, and at what level you want to distinguish this)
> But let's suppose that the application is normally installed at (tomcat)/webapps/app1,
> responds to URLs like "/app1/*".
> If the "/webapps/app1" application is not there, then Tomcat will try to map this to
> default application, "/webapps/ROOT/app1/*".  Then it will probably not find it there
> either, and return a 404 response.
> If the application is there, then Tomcat will (succesfully) map the call to
> /webapps/app1/*", and the application will respond. And, maybe, it will sometimes respond
> with a 404.
> So two possible solutions :
> 1) change the application, so that in such a case, it responds with something else than
> 2) install something in /ROOT, which will catch everything that gets there, and respond
> with something else than 404.
> That supposes of course that you do not previously have a default application under
> /webapps/ROOT.

Addendum :
The above suggests a (possible) way to do this at the Tomcat level.
But you also mention "mod_jk", which implies that you have Apache httpd acting as a 
front-end to Tomcat and this application.

You could also do this at the Apache httpd level.
For Apache httpd, mod_jk (and all that is behind it, but that Apache httpd does not know 
or care about) is seen as the "application", which generates the HTTP response.
To filter such a response and possibly modify it before it goes back to the client, you 
would have to use an "output filter" at the Apache httpd level.
Start from here :

But again, you did not really indicate the level at which you need this, or for what 
ultimate purpose, so it is not easy to recommend a "better" solution.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message