tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: JSP in Static Resources
Date Sun, 14 Jul 2013 21:28:25 GMT
Alireza Fattahi wrote:
> Well,
> If we want to follow up that post , then we should belive that:

Tomcat is an inclusive church, and you can believe what you want.
Konstantin is one of the Tomcat developers however, so you should probably consider what 
he wrote and try to understand it correctly.

> Setting the mime type is not working for css

That is not what he wrote.

Setting the MIME type in (tomcat)/conf/web.xml /does/ work, for the default servlet which

is used by default in all webapps to serve static documents.
But in the case of the logic which you want to implement, the CSS is not a static 
document, so it is not relevant to your specific case.

He gave you the proper syntax for Tomcat 7, because previously you did not mention the 
Tomcat version that you were using.

For Tomcat 6, that syntax doesn't work.

> So
> we should use other ways to solve it.

Yes. The first option would be to use Tomcat 7 instead of Tomcat 6.
Then the syntax shown by Konstantin would work.

Otherwise, he gave you one hint of how to try to solve it.

Another possibility would be to wrap your webapp with a servlet filter, and set the 
content-type header there, before the content is written to the response object.

Another possibility would be to re-think your logic, and leave you CSS files be static 
documents, and just pick the one you need to include.

That you want or don't want to use a certain logic is your choice; but if you pick a logic

which is difficult to implement in the version of the software that you are using, then 
the problem to implement it is ultimately yours.

> Is that true?!  
> ~Regards,
> ~~Alireza Fattahi
> ________________________________
> From: André Warnier <>
> To: Tomcat Users List <> 
> Sent: Sunday, 14 July 2013, 12:00
> Subject: Re: JSP in Static Resources
> Alireza Fattahi wrote:
>> Guys please concentrate on the main issue !!
> I believe that "the main issue" was already answered thoroughly by Konstantin earlier.
> Did you not read it ?
>> I ask again:
>> When you set jsp servlet to process the css files by adding:
>> <servlet-mapping>
>>     <servlet-name>jsp</servlet-name>
>>     <url-pattern>*.css</url-pattern>
>> </servlet-mapping>
>> The tomcat does not set the CSS file extension mime type to text/css. Although below
line is set in localhost-config/web.xml
>>     <mime-mapping>
>>         <extension>css</extension>
>>         <mime-type>text/css</mime-type>
>>     </mime-mapping>
>> When you manually set the content mime type <%@page contentType="text/css" %>
every thing will work fine
>> ~Regards,
>> ~~Alireza Fattahi
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message