tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lentes, Bernd" <>
Subject AW: specifying the content-type
Date Thu, 02 Jun 2011 13:06:38 GMT

Andre Warnier wrote:

> On 6/1/2011 1:04 PM, Lentes, Bernd wrote:
>>> Okay. Can you post your servlet code, then?
>> I have to ask our developers.
> Okay.
>>> There is no default Content-Type for HTTP responses, so
>>> getting a response directly from Tomcat might cause the
>>> browser to auto-detect content.
>> That's what i also believe.
> Sounds like Martin Kuen and I had the same idea moments apart.
>>> You might want to properly set the Content-Type header in
>>> your servlet code if you aren't already doing it.
>> How can i do that ?
> You'd have to modify the code like this:
>   response.setContentType("text/html");
> (or whatever content type is appropriate in the situation).
> Use of mod_headers or something similar may get this taken care of more
> quickly, but fixing the code is a better long-term approach.

> Sorry guys, but it still does not make sense :

> The response is interpreted perfectly OK when it comes through the HTTP Connector of
> Tomcat, on port 8080.
> But it is not interpreted OK when it comes through the AJP Connector, on port 8009.

> If it was a question of a header set or not set by the servlet, it would be the same
> both cases, no ?

> Mmmm, now I get a new suspicion :

> Because the Tomcat app does not set a content-type :
> - in the case where the browser connects directly to Tomcat, the response comes without
> content-type, so the browser "sniffs" and guesses itself, and it happens to do it right.
> - but in the case where the response goes through Apache httpd, Apache sees that there
> no content-type, and adds a "text/plain" one.
> (Nothing to do with AJP/mod_jk, it is Apache who done it)

> That should be visible at the browser level, using a plugin like HttpFox (Firefox) or
> Fiddler2 (IE).

I mentioned that already :

tcpdump shows that the content delivered by httpd has a content-type of text/plain, the content
delivered by tomcat has no content-type. So Andre,
your assumption is right.
httpfox would show the same.

I will check if i'm able to set the content-type in httpd, otherwise our developers have to
add a header in the http-response, setting the right content type, or we will try a meta element
in the head of the
html code, setting the content-type.

I will keep you informed.

Helmholtz Zentrum München
Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH)
Ingolstädter Landstr. 1
85764 Neuherberg
Aufsichtsratsvorsitzende: MinDir´in Bärbel Brumme-Bothe
Geschäftsführer: Prof. Dr. Günther Wess und Dr. Nikolaus Blum
Registergericht: Amtsgericht München HRB 6466
USt-IdNr: DE 129521671
View raw message