users@glassfish.java.net

Re: Configure Glassfish Mime-Types

From: Joerg Gippert <jgippert_at_online.de>
Date: Mon, 17 Mar 2008 20:50:55 +0100

Hello,

thank you for the reply. In the meanwhile, I have done som further testing
on this issue. The problem was, that Firefox (IE and Opera do) does not load
the stylesheet that I have defined in my JSP. FF says, the stylesheet could
not be loaded since it has the wrong MIME-type (text/plain or text/html
instead of text/css).

I narrowed it down to the DOCTYPE in my JSP. If I remove the line "
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">" FF displays the
page correctly. But only because FF falls back into a less restrictive
interpretation mode if the DOCTYPE is missing. I use Myfaces and Acegi
Security system. For a test, I excluded both from my web.xml to avoid any
conflicts. Still the same problem. If I open the CSS file in the browser
directly (e.g. http://myhost/webapp/jsp/styles.css) the header also show the
content type as "text/html". The admin gui of Glassfish btw. is displayed
normally. I couldn't find the jsp source code on the glassfish project
website though (all directories appear to me as "empty").

Can I somehow bypass the default-web.xml? Not, that I wanted to but
obviously I manaegd to get around it. Do you have any ideas how to fix that
problem?

Thanks in advance!

Cheers,
Joerg



----- Original Message -----
From: <Jan.Luehe_at_Sun.COM>
To: <users_at_glassfish.dev.java.net>
Sent: Monday, March 17, 2008 6:30 PM
Subject: Re: Configure Glassfish Mime-Types


> 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
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>