tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: mod_proxy_ajp JSESSIONID and Mime Type
Date Fri, 15 Jan 2010 18:04:47 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Darren,

On 1/4/2010 2:10 PM, Darren Salomons wrote:
> Since my servlet excepts all types of file types I thought I would just 
> leverage apache setting the content-type for me.

This is a bad assumption: if you want your servlet to serve files of
types other than text/plain, your servlet should be explicitly setting
the content type in the response. Apache httpd should respect that
content type and not change it.

> This only works 
> because apache is smart enough to pick up the extension on the response 
> url and append the correct mime type to the content-type header.  The 
> problem is that when the JSESSIONID is appended onto the URL it defaults 
> the mime type to text/plain regardless of the extension.   This seems 
> like a bug but I'm not sure if this a problem with mod_proxy or 
> mod_proxy_ajp.

The problem is with neither of these: Apache httpd uses the file
extension to determine the MIME type and therefore the content type of
the response. When you add ";jsessionid=asdjkawdlhfk" to the URL, Apache
treats that as part of the filename so the extension looks like a bunch
of junk, and maps to no known MIME type.

One could argue that the treatment of ";jsessionid=..." as a part of the
path is a bug (and there are those who have argued such), but the httpd
team seems content to allow things to remain that way.

The solution is to provide a proper content type from the servlet.

Konstantin's suggestion to use ServletContext.getMimeType is a good one,
as it's designed explicitly for this scenario.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAktQrj8ACgkQ9CaO5/Lv0PBI2ACghVEWHP9vPK1+lRR9E+21RruG
0AkAmwYKaSTNMpj3IofjMyVRQVzk82BI
=VTc0
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message