tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alireza Fattahi <afatt...@yahoo.com>
Subject Re: JSP in Static Resources
Date Mon, 15 Jul 2013 07:03:16 GMT
Thanks for help!

Let me summarize:

There are two servlets as below:
1- Default servlet which process all static resources
2- jsp servlet which process the JSP file

The mime types ( which are defined in localhost-config/web.xml) are only used bydefault servlet.


When I ask the jsp servlet to process the .css files, this servlet will always set the MIME
to text/html.

So this problem could be solved  if the servlet mapping has something like mime-type as below:
<servlet-mapping>
    <servlet-name>jsp</servlet-name>
    <url-pattern>*.css</url-pattern>
   <mime-type>text/css</mime-type>
</servlet-mapping>
I should ask jcp.org to put this in next servlet jsr !!


So, may be I try to write a servlet to set the content type.
Do you know if tomcat has a build in filter or servlet for that.
Some thing like: org.apache.catalina.filters.SetCharacterEncodingFilter which sets the encoding

    

 
~Regards,
~~Alireza Fattahi


________________________________
 From: André Warnier <aw@ice-sa.com>
To: Tomcat Users List <users@tomcat.apache.org> 
Sent: Monday, 15 July 2013, 1:58
Subject: Re: JSP in Static Resources
 

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 <aw@ice-sa.com>
> To: Tomcat Users List <users@tomcat.apache.org> 
> 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: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message