Lentes, Bernd wrote:
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 in
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 is
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.
As others already mentioned, setting the proper header at the Tomcat webapp level would be
the best solution (and a "clean" application should do that anyway).
Trying to set the header at the Apache httpd level is not so clean, because for instance
there may be different kinds of responses/documents sent by Tomcat (now or in the future),
and not all will be html in nature (think of images, stylesheets e.g.). (and I also saw
javascript files in your Tomcat directories, if I recall correctly.
So in the end your header-setting logic at the Apache level would have to be quite
complicated to do the job correctly.
By the way, my initial scepticism and suppositions were wrong of course, but I was just
following a logical path of most likely to less likely, using the available information.
Most people coming to this list for help are less thorough than you are, and easily fall
prey to the kind of misconfiguration which I mentioned. Luckily for me in a way, because
it provides me with some areas in which I can at least try to help.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org