users@glassfish.java.net

Re: Configure Glassfish Mime-Types

From: <Jan.Luehe_at_Sun.COM>
Date: Mon, 17 Mar 2008 10:30:04 -0700

Joerg,

Joerg Gippert wrote:

> Hello,
>
> I am trying to change a Mime-Type mapping on Glassfish but I cannot
> find any documentation on how to do that. I am using Glassfish V2
> build b33. The problem I encouter is, that my webpage hosted on my
> glassfish server is not displayed properly with Firefox browsers. FF
> complains, that stylesheet I use in m JSP is of Mime-Type text/plain
> and not text/css. Which is true if I look at the header, Glassfish
> sends to the broswer:
>
> GET /myWeb/faces/jsp/neu.css HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.7.5)
> Gecko/20041122 Firefox/1.0
> Accept: text/css,*/*;q=0.1
> Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;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
> HTTP/1.x 200 OK
> X-Powered-By: Servlet/2.5, JSF/1.2
> Server: Sun Java System Application Server 9.1
> Content-Type: text/plain; charset=iso-8859-1 <-------------- should
> be text/css
> Content-Length: 4709
> This problem seems to only occuring with Firefox. It does not appear
> with Opera or IE. Can anybody tell me, how I can make Glassfish to
> send out the proper Mime-Type?


the mime-type mapping you are looking for is already defined in the
domain's default-web.xml,
which is inherited by all webapps:

  <mime-mapping>
    <extension>css</extension>
    <mime-type>text/css</mime-type>
  </mime-mapping>

If I request a ".css" resource directly, I do see the correct
Content-Type in the response:

  Content-Type: text/css

I noticed your X-Powered-By response header includes "JSF/1.2", which
means that
the Content-Type of your response may not be looked up in
default-web.xml directly ...


Jan


>
> Thanks in advance.
> Cheers,
> Joerg
>