tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject [users@httpd] Problem with mod_headers ?
Date Tue, 30 Dec 2008 19:27:39 GMT

The following is verbatim what I posted earlier on the Apache user's 
list.  I am reposting it here because I did not really get a 
"satisfactory" answer on the Apache httpd list, and because I know that 
mod_jk experts lurk around here. And maybe this has something to do with 
the fact that the requests we're talking about are handled by a Tomcat 
webapp, after being re-directed by Apache/mod_jk.

The underlying question is also : despite what I'm saying below about 
not being able to change the webapp (which is basically true), I think I 
should be able to change the Content-Type header (which I believe is 
generated by the rogue webapp or by Tomcat itself), *before* it gets 
sent back to Apache via mod_jk.
And I guess that in order to do that, I would have to create a servlet 
filter that acts at the output level.  How hard would that be to do ?

(I already have a servlet filter around this webapp, but at the moment 
it only acts on the input side).

Original message to Apache list follows :

I am a bit at my wit's end here.

Using Apache 2.2.3 under Suse Linux, with a mod_jk re-director to Tomcat 
(5.0.x) for certain links, such as the one of which question below.

I am using a Tomcat java application which unfortunately sets the
Content-Type response header wrongly : it says "text/html;
charset=iso-8859-1" instead of "text/html; charset=iso-8859-2", and
there is no way I can change that application itself.
So I am trying to rectify that header after-the-fact, using mod_headers.
Unfortunately, it does not seem to work.

I have this Vhost configuration (snippet) :

SetEnvIf REQUEST_URI "/servlet\.[^\.]+$" is-jk
Header always set Content-Type: "text/html; charset=ISO-8859-2" env=is-jk
Header always set Test-Header: "VHost level" env=is-jk

<LocationMatch "/servlet\.[^.]+$">
   SetHandler jakarta-servlet
   Header always set Content-Type: "text/html; charset=ISO-8859-2"
   Header always set Test-Header: "Location level"

I capture the HTTP headers resulting from a request, using the
LiveHttpHeaders plugin of Firefox, as follows (sorry for the email
wrap-around, and sensitive bits edited-out with XXX):

POST /starweb/XXX/servlet.starweb HTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:
Gecko/20080623 Firefox/
Accept-Language: en-gb,en;q=0.7,de-de;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
Content-Length: 273

HTTP/1.x 200 OK
Date: Tue, 30 Dec 2008 17:30:33 GMT
Server: Apache/2.2.3 (Linux/SUSE) mod_jk/1.2.28-dev-727724
mod_perl/2.0.2 Perl/v5.8.8
Content-Type: text/html;charset=ISO-8859-1
Test-Header: Location level
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Pragma: no-cache
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked

As can be seen above, the "Test-Header" that I set with mod_headers
comes out perfectly, from the Location section.
But the Content-Type header, which I believe should be set in the same
exact conditions, does not.

Does anyone have an idea why ?


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

View raw message