Re: JSP in Static Resources
Hi, I am using YAML framework for layout management, it has lot's of css files to be changed, and on the other hand, if I want to set the contentType manually I should do it every time I upgrade the YAML framework. ~Regards, ~~Alireza Fattahi From: Leon Rosenberg rosenberg.l...@gmail.com To: Tomcat Users List users@tomcat.apache.org; Alireza Fattahi afatt...@yahoo.com Sent: Monday, 15 July 2013, 4:44 Subject: Re: JSP in Static Resources Hello Alireza, what exactly was wrong with putting contentType=text/css;charset=UTF-8 on top of your css-jsps? Actually each page should have content-type, so why not the css jsps? Leon On Sun, Jul 14, 2013 at 12:43 PM, Alireza Fattahi afatt...@yahoo.com wrote: Well, If we want to follow up that post , then we should belive that: Setting the mime type is not working for css So we should use other ways to solve it. Is that true?! ~Regards, ~~Alireza Fattahi From: André Warnier a...@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-namejsp/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 extensioncss/extension mime-typetext/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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: JSP in Static Resources
Good point, I did not think about it ! Please let me know this: If I have an static html page ( like and about.html page) and I change the extension to to jsp (about.js) , then the tomcat will not cache it any more?! I try to google tomcat caching and could not find any thing useful. Can you please give me some references about caching? ~Regards, ~~Alireza Fattahi From: Tim Watts t...@cliftonfarm.org To: Tomcat Users List users@tomcat.apache.org Sent: Monday, 15 July 2013, 3:23 Subject: Re: JSP in Static Resources On Sun, 2013-07-14 at 23:28 +0200, André Warnier wrote: 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. Another drawback to generating the CSS files dynamically is that you'll have to do extra work to make them cacheable. But when served as static resources, the default servlet does a good job of this for you. If you don't take steps to make them cacheable, they'll be fetched every time on every page adding extra load on your server and the network. Is that true?! ~Regards, ~~Alireza Fattahi From: André Warnier a...@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-namejsp/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 extensioncss/extension mime-typetext/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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: JSP in Static Resources
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-namejsp/servlet-name url-pattern*.css/url-pattern mime-typetext/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 a...@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 a...@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-namejsp/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 extensioncss/extension mime-typetext/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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: JSP in Static Resources
Alireza Fattahi wrote: Good point, I did not think about it ! What is a good point ? That is what Konstantin meant, when he asked you to not top post. If you comment or answer questions on top of your message, then someone has to scroll down the message and try to figure out to what your comment relates, or what question you are answering. Many people won't bother. Insert your answers directly below the question/comment to which it relates, please. Please let me know this: If I have an static html page ( like and about.html page) and I change the extension to to jsp (about.js) , then the tomcat will not cache it any more?! Wrong explanation. It has nothing to do with the extension. The point is : it is only possible to cache a *static* document. That is true at the server level, and at the browser level. If a document is generated dynamically, using some code, then the caching logic has no way to determine if this thing changes from one call to the next, and thus caching previous responses is useless. A response generated by a JSP (whether it is HTML, CSS or anything else) is dynamic by nature, and cannot/should not be cached. In other words, the very subject of this thread does not really make sense : if you add Java code into a static resource and thus make it into a JSP, it is not static anymore. You can probably find a way to trick the caching mechanisms into believing that a dynamic response is static. But then you will create severe problems in the usage of your application, because clients will start using outdated versions of the pages, instead of the correct ones. I try to google tomcat caching and could not find any thing useful. Can you please give me some references about caching? ~Regards, ~~Alireza Fattahi From: Tim Watts t...@cliftonfarm.org To: Tomcat Users List users@tomcat.apache.org Sent: Monday, 15 July 2013, 3:23 Subject: Re: JSP in Static Resources On Sun, 2013-07-14 at 23:28 +0200, André Warnier wrote: 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. Another drawback to generating the CSS files dynamically is that you'll have to do extra work to make them cacheable. But when served as static resources, the default servlet does a good job of this for you. If you don't take steps to make them cacheable, they'll be fetched every time on every page adding extra load on your server and the network. Is that true?! ~Regards, ~~Alireza Fattahi From: André Warnier a...@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-namejsp/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 extensioncss/extension mime-typetext/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
Re: JSP in Static Resources
~Regards, ~~Alireza Fattahi From: André Warnier a...@ice-sa.com To: Tomcat Users List users@tomcat.apache.org Sent: Monday, 15 July 2013, 12:09 Subject: Re: JSP in Static Resources Alireza Fattahi wrote: Good point, I did not think about it ! What is a good point ? *** Considering the caching which I forget about it! That is what Konstantin meant, when he asked you to not top post. If you comment or answer questions on top of your message, then someone has to scroll down the message and try to figure out to what your comment relates, or what question you are answering. Many people won't bother. Insert your answers directly below the question/comment to which it relates, please. ** I do not prefer this way and find that lots of posts do not send emails this way. ** As, it makes the thread hard to understand, after three or four post. ** But you are the boss ! Please let me know this: If I have an static html page ( like and about.html page) and I change the extension to to jsp (about.js) , then the tomcat will not cache it any more?! Wrong explanation. It has nothing to do with the extension. * So how tomcat finds which resources are static ?! The point is : it is only possible to cache a *static* document. That is true at the server level, and at the browser level. If a document is generated dynamically, using some code, then the caching logic has no way to determine if this thing changes from one call to the next, and thus caching previous responses is useless. A response generated by a JSP (whether it is HTML, CSS or anything else) is dynamic by nature, and cannot/should not be cached. That is my point too. Where this logic is defined ?! is it hard coded ? How tomcat find if some request is static and could be cached. For example request to http://localhost/mysite/contact.pdf will be cached at server or not ! How can I find it ?! In other words, the very subject of this thread does not really make sense : if you add Java code into a static resource and thus make it into a JSP, it is not static anymore. You can probably find a way to trick the caching mechanisms into believing that a dynamic response is static. But then you will create severe problems in the usage of your application, because clients will start using outdated versions of the pages, instead of the correct ones. Still looking for some reference documents about tomcat caching configuration ! Thanks for your help! I try to google tomcat caching and could not find any thing useful. Can you please give me some references about caching? ~Regards, ~~Alireza Fattahi From: Tim Watts t...@cliftonfarm.org To: Tomcat Users List users@tomcat.apache.org Sent: Monday, 15 July 2013, 3:23 Subject: Re: JSP in Static Resources On Sun, 2013-07-14 at 23:28 +0200, André Warnier wrote: 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. Another drawback to generating the CSS files dynamically is that you'll have to do extra work to make them cacheable. But when served as static resources, the default servlet does a good job of this for you. If you don't take steps to make them cacheable, they'll be fetched every time on every page adding extra load on your server and the network. Is that true?! ~Regards, ~~Alireza Fattahi
Re: JSP in Static Resources
On 15/07/2013 08:03, Alireza Fattahi wrote: 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-namejsp/servlet-name url-pattern*.css/url-pattern mime-typetext/css/mime-type /servlet-mapping I should ask jcp.org to put this in next servlet jsr !! You'd be wasting your time. The specifications (Servlet 2.5, JSP 2.1) that Tomcat 6 is based on aren't going to change. The specification that Tomcat 7 is based on (Servlet 3.0, JSP 2.2) already - as Konstantin has pointed out - contain a feature that let you do effectively the same thing in web.xml. The specifications that Tomcat 8 is based on (Servlet 3.1, JSP 2.3) are now final and - as the specifications place a high importance on compatibility - still contain the feature Konstantin told you about. The work on the specifications that Tomcat 9 will be based on hasn't started yet but as a member of one the expert groups that would consider the proposal above I can tell you that my view would be to reject it as unnecessary bloat. 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 No, but it would be trivial to write one. Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: [OT] JSP in Static Resources
Alireza Fattahi wrote: ~Regards, ~~Alireza Fattahi From: André Warnier a...@ice-sa.com To: Tomcat Users List users@tomcat.apache.org Sent: Monday, 15 July 2013, 12:09 Subject: Re: JSP in Static Resources Alireza Fattahi wrote: Good point, I did not think about it ! What is a good point ? *** Considering the caching which I forget about it! That is what Konstantin meant, when he asked you to not top post. If you comment or answer questions on top of your message, then someone has to scroll down the message and try to figure out to what your comment relates, or what question you are answering. Many people won't bother. Insert your answers directly below the question/comment to which it relates, please. ** I do not prefer this way and find that lots of posts do not send emails this way. ** As, it makes the thread hard to understand, after three or four post. ** But you are the boss ! It is not that I am the boss (which I am not), it is that these are the rules of this Tomcat users list. The people who are *donating* their time here to answer your questions, prefer it that way. Independently of your own preferences or what other lists do, you should respect that, if you ask the people here for their time in resolving your issues. That is just basic politeness. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: [OT] JSP in Static Resources
~Regards, ~~Alireza Fattahi From: André Warnier a...@ice-sa.com To: Tomcat Users List users@tomcat.apache.org Sent: Monday, 15 July 2013, 12:09 Subject: Re: JSP in Static Resources Alireza Fattahi wrote: Good point, I did not think about it ! What is a good point ? *** Considering the caching which I forget about it! That is what Konstantin meant, when he asked you to not top post. If you comment or answer questions on top of your message, then someone has to scroll down the message and try to figure out to what your comment relates, or what question you are answering. Many people won't bother. Insert your answers directly below the question/comment to which it relates, please. ** I do not prefer this way and find that lots of posts do not send emails this way. ** As, it makes the thread hard to understand, after three or four post. ** But you are the boss ! It is not that I am the boss (which I am not), it is that these are the rules of this Tomcat users list. The people who are *donating* their time here to answer your questions, prefer it that way. Independently of your own preferences or what other lists do, you should respect that, if you ask the people here for their time in resolving your issues. That is just basic politeness. *** Thanks for *donating* your time ! - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: JSP in Static Resources
Alireza Fattahi wrote: 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 yes. The mime types ( which are defined in localhost-config/web.xml) are only used bydefault servlet. Yes, but you should remove the parenthesis. When I ask the jsp servlet to process the .css files, this servlet will always set the MIME to text/html. By default, yes, the JSP servlet sets the content-type to HTML. This is a *default*, and it is chosen this way to save precious programmer keystrokes to state the content-type explicitly, for the majority of cases (because overwhelmingly, JSP pages usually return HTML content). So it belongs to the programmer to explicitly specify the content-type, it it does not match the default. This is the case for *any non-HTML* content, whether it is CSS, Javascript, images or whatever. So this problem could be solved if the servlet mapping has something like mime-type as below: servlet-mapping servlet-namejsp/servlet-name url-pattern*.css/url-pattern mime-typetext/css/mime-type /servlet-mapping Yes, but you should realise that this is syntactic sugar : it saves some keystrokes for the programmer, at the cost of making the server more bloated. Just like for standard HTML, each page should contain an indication of what it's content is. I should ask jcp.org to put this in next servlet jsr !! See Mark's answer. 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 See Mark's answer. Alireza, (hoping that this is your first name) basically my own opinion is : Your idea of incorporating Java code into the CSS pages, to achieve what you want, is clever, and it is technically possible. But the fact that it is clever and technically possible does not mean that you should necessarily do it that way. That way of doing it, in my view, has a number of disadvantages which more than compensate for the cleverness : it would not work under all versions of all servers, it does not allow caching of the CSS files, it makes it more difficult to understand and maintain the pages of your website, and it makes things so that your CSS pages are not really pure CSS pages anymore. It also makes it so that each time your server will serve a CSS page, it will have to run a few tens of thousands of additional CPU cycles, compared to having the CSS files as pure static documents. And it willhave to do this more often, because they are not static anymore and will not be cached by the browsers and/or server. I would not do it that way, and I would try to apply the cleverness somewhere else. You have the real JSP pages of your site, which /must/ already be compiled and executed via the JSP process anyway. One additional instruction in these pages is not going to make a big difference. But making the CSS pages go from being static to being dynamic is a big difference, with a series of side-effects now and in the future that are difficult to predict. But it's your application and your choice. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: JSP in Static Resources
~Regards, ~~Alireza Fattahi From: André Warnier a...@ice-sa.com To: Tomcat Users List users@tomcat.apache.org Sent: Monday, 15 July 2013, 14:13 Subject: Re: JSP in Static Resources Alireza Fattahi wrote: 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 yes. The mime types ( which are defined in localhost-config/web.xml) are only used bydefault servlet. Yes, but you should remove the parenthesis. When I ask the jsp servlet to process the .css files, this servlet will always set the MIME to text/html. By default, yes, the JSP servlet sets the content-type to HTML. This is a *default*, and it is chosen this way to save precious programmer keystrokes to state the content-type explicitly, for the majority of cases (because overwhelmingly, JSP pages usually return HTML content). So it belongs to the programmer to explicitly specify the content-type, it it does not match the default. This is the case for *any non-HTML* content, whether it is CSS, Javascript, images or whatever. So this problem could be solved if the servlet mapping has something like mime-type as below: servlet-mapping servlet-namejsp/servlet-name url-pattern*.css/url-pattern mime-typetext/css/mime-type /servlet-mapping Yes, but you should realise that this is syntactic sugar : it saves some keystrokes for the programmer, at the cost of making the server more bloated. Just like for standard HTML, each page should contain an indication of what it's content is. I should ask jcp.org to put this in next servlet jsr !! See Mark's answer. 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 See Mark's answer. Alireza, (hoping that this is your first name) Yes André my name is Alireza !! basically my own opinion is : Your idea of incorporating Java code into the CSS pages, to achieve what you want, is clever, and it is technically possible. But the fact that it is clever and technically possible does not mean that you should necessarily do it that way. That way of doing it, in my view, has a number of disadvantages which more than compensate for the cleverness : it would not work under all versions of all servers, it does not allow caching of the CSS files, it makes it more difficult to understand and maintain the pages of your website, and it makes things so that your CSS pages are not really pure CSS pages anymore. It also makes it so that each time your server will serve a CSS page, it will have to run a few tens of thousands of additional CPU cycles, compared to having the CSS files as pure static documents. And it willhave to do this more often, because they are not static anymore and will not be cached by the browsers and/or server. I would not do it that way, and I would try to apply the cleverness somewhere else. You have the real JSP pages of your site, which /must/ already be compiled and executed via the JSP process anyway. One additional instruction in these pages is not going to make a big difference. But making the CSS pages go from being static to being dynamic is a big difference, with a series of side-effects now and in the future that are difficult to predict. But it's your application and your choice. * Thanks for your comments * I already see sites that do this. * For example please visit these three sites: * http://en.wikipedia.org/wiki/Apache_Tomcat * View source * link rel=stylesheet href=//bits.wikimedia.org/en.wikipedia.org/load.php?debug=falseamp;lang=enamp;modules=ext.gadget.DRN-wizard%2CReferenceTooltips%2Ccharinsert%2Cteahouse%7Cext.rtlcite%2Cwikihiero%7Cext.uls.nojs%7Cmediawiki.legacy.commonPrint%2Cshared%7Cmw.PopUpMediaTransform%7Cskins.vectoramp;only=stylesamp;skin=vectoramp;* / * the load.php makes a dynamic css * Please visit www.ebay.com * View source * link href=http://gh.ebaystatic.com/header/css/all.min?combo=11ds=3siteid=0rvr=93h=22235; type=text/css rel=stylesheet ** the all.min loads dynamic css ** Even facebook uses dynamic css. ** Do you think I am wrong ? ** All these site are multilinguala and bidirectional sites. This is the case which force them ** make the css files generate dynamically. ** When you work on these types of sites there is always a trade off to make some thing like this: ** mysite/style/fa_IR/style.css ** mysite/styles/en_US/style.css ** mysite/styles/ar_AU/style.css ** or making one css and try put if statements in it. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
Re: JSP in Static Resources
... * Thanks for your comments * I already see sites that do this. * For example please visit these three sites: * http://en.wikipedia.org/wiki/Apache_Tomcat * View source * link rel=stylesheet href=//bits.wikimedia.org/en.wikipedia.org/load.php?debug=falseamp;lang=enamp;modules=ext.gadget.DRN-wizard%2CReferenceTooltips%2Ccharinsert%2Cteahouse%7Cext.rtlcite%2Cwikihiero%7Cext.uls.nojs%7Cmediawiki.legacy.commonPrint%2Cshared%7Cmw.PopUpMediaTransform%7Cskins.vectoramp;only=stylesamp;skin=vectoramp;* / * the load.php makes a dynamic css * Please visit www.ebay.com * View source * link href=http://gh.ebaystatic.com/header/css/all.min?combo=11ds=3siteid=0rvr=93h=22235; type=text/css rel=stylesheet ** the all.min loads dynamic css ** Even facebook uses dynamic css. ** Do you think I am wrong ? Yes. It is more likely that they are dynamically determining which static .css page to load, rather than dynamically *creating* the .css. That is one option that was previously suggested in this thread. Doing that allows caching to work, reducing both server and network load. ** All these site are multilinguala and bidirectional sites. This is the case which force them ** make the css files generate dynamically. As above, it is more likely they are *selecting* the .css dynamically, rather than generating it. ** When you work on these types of sites there is always a trade off to make some thing like this: ** mysite/style/fa_IR/style.css ** mysite/styles/en_US/style.css ** mysite/styles/ar_AU/style.css ** or making one css and try put if statements in it. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: JSP in Static Resources
-Original Message- From: Alireza Fattahi [mailto:afatt...@yahoo.com] Sent: Monday, July 15, 2013 1:10 AM To: Tomcat Users List Subject: Re: JSP in Static Resources Hi, I am using YAML framework for layout management, it has lot's of css files to be changed, and on the other hand, if I want to set the contentType manually I should do it every time I upgrade the YAML framework. This is a fallacious argument, as you will have to manually re-add your JSP changes every time you upgrade. Jeff ~Regards, ~~Alireza Fattahi From: Leon Rosenberg rosenberg.l...@gmail.com To: Tomcat Users List users@tomcat.apache.org; Alireza Fattahi afatt...@yahoo.com Sent: Monday, 15 July 2013, 4:44 Subject: Re: JSP in Static Resources Hello Alireza, what exactly was wrong with putting contentType=text/css;charset=UTF-8 on top of your css-jsps? Actually each page should have content-type, so why not the css jsps? Leon On Sun, Jul 14, 2013 at 12:43 PM, Alireza Fattahi afatt...@yahoo.com wrote: Well, If we want to follow up that post , then we should belive that: Setting the mime type is not working for css So we should use other ways to solve it. Is that true?! ~Regards, ~~Alireza Fattahi From: André Warnier a...@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-namejsp/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 extensioncss/extension mime-typetext/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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: [OT] JSP in Static Resources
-Original Message- From: Alireza Fattahi [mailto:afatt...@yahoo.com] Sent: Monday, July 15, 2013 4:12 AM To: Tomcat Users List Subject: Re: [OT] JSP in Static Resources ~Regards, ~~Alireza Fattahi From: André Warnier a...@ice-sa.com To: Tomcat Users List users@tomcat.apache.org Sent: Monday, 15 July 2013, 12:09 Subject: Re: JSP in Static Resources Alireza Fattahi wrote: Good point, I did not think about it ! What is a good point ? *** Considering the caching which I forget about it! That is what Konstantin meant, when he asked you to not top post. If you comment or answer questions on top of your message, then someone has to scroll down the message and try to figure out to what your comment relates, or what question you are answering. Many people won't bother. Insert your answers directly below the question/comment to which it relates, please. ** I do not prefer this way and find that lots of posts do not send emails this way. ** As, it makes the thread hard to understand, after three or four post. ** But you are the boss ! It is not that I am the boss (which I am not), it is that these are the rules of this Tomcat users list. The people who are *donating* their time here to answer your questions, prefer it that way. Independently of your own preferences or what other lists do, you should respect that, if you ask the people here for their time in resolving your issues. That is just basic politeness. *** Thanks for *donating* your time ! Perhaps we should suggest he inquire of Martin Gainty for help on this problem. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: JSP in Static Resources
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Alireza, On 7/13/13 6:13 AM, Alireza Fattahi wrote: I just find a bad work around which you must put %@page contentType=text/css %in top of all css files Why don't you want to do this? This is actually the proper way to do things. Perhaps you could split your CSS files into static and dynamic, like this: servlet-mapping servlet-namejsp/servlet-name url-pattern/css/dynamic/*.css/url-pattern /servlet-mapping Now, you only need to put the @page directive in CSS files that are actually dynamic. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBCAAGBQJR5Cn3AAoJEBzwKT+lPKRYIo0P/3zQ/k49aqwapnwnjAIZlXZg JgD9FH0bBKJVWca7wYY9Qn0ugr+8z2kTwcE1X8bKtvaiHyTJlzV70Y6Z9L2qNGcA dPNPcrUnEO4K+8E4xGVjeJ5UnqSIa6xj4nqmRmiSEpEztTZVjXGlqzBFUrNO5Gob rwxtZHD5WJL8NMsfKPROXVY47wSl7BH9JHd9A3etiYbPgMXNhLKTOA6zv330OVgo DpDpoVQsPkiRisruVma8runc78My4dcWbB0oKA40x5AJNCU52KRvncsM7hJNqtas Se3N04JB26XsPPelkqvfBlMIzIpV1Y6W4yDg1TQfosj6Mvg+Rk2vw0eXD0xoL94+ 2GtAGN0peVNqx4QmBFXWDIQ7qpBDMjyrPQSZbUY3iUoSFuBC9oFMczayIJBThE4+ m8g8bbQunopDKPsqCU1Gv/4so9DIu9KO6D7k72DUoigsRnb+eyfEpeH8cqd63qrc WS3Tuos08cw4p+uG2rLP3U3j8fzKCEarevjYa62VTynN613hA3ElgQl+wcP+QRvC Qlhnz4V+wM4o8DuW0w/u5XzTbPerYMsE+1WxSL/wssIWLownbX/OweSITwgMD1r2 J32Q7fUoYV8ib2AUotSo957LkkE9D0BJi3edlytsgQoj01C/tnBztw6bN8zaaAvI ezJ7aZNKYfxTCl/uFjBZ =J4yg -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: JSP in Static Resources
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Alireza, On 7/15/13 2:10 AM, Alireza Fattahi wrote: I am using YAML framework for layout management, it has lot's of css files to be changed, and on the other hand, if I want to set the contentType manually I should do it every time I upgrade the YAML framework. Why not simply change your header document to include the conditional LTR vs. RTL logic, and then include the proper set of CSS resources? That would seem to be the simplest possible solution: one change in one place and everything works properly. You do have a header document, right? - -chris -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBCAAGBQJR5CxFAAoJEBzwKT+lPKRYJywP/1cpJ0upi/uQYU4K8qMkiPtD O6S9lAyWLOJUp6W1d8KKLrR6ykxYB1DRESmSZsktWsoTrud0Z69cpRipnBG+wMeS d5LJmTbA5udErNkNftdiS7iVyY0TeSN+K+fDIPDUD5gt3gEB2iBKAhSq/SdkhKqS vdZ6/wIinooxPD+Zdp2E76o2xF8Trq2tHh+Yi28jHtZfHP+zLdOYVkV5tTSaBvr/ EkU4s0eoFfNY2ZUi6qXREndt5iNgeruZ2FArzFHAjrou/Fkt3o7JnuPhsEtNnJfW 9pEATxUbdq1JahwKFhdUWGwS2i7CyDjr9jkP/hZRgYqhnSxcMcUDru9EP7ZB+x/u f6ucMDPyZa+MfW7SHJMFzxf4lFq25pnlwm+fsvF9wwLrGV39/bOixVRiCMxoVdSe oLmWQ5KGBdTefZyTmrEJ+jUky8usVyst3rX0IJzIwtAwSoRkyWFOvRdqoDBqlbHZ V9n3HqPsJkNaPhvEldRBeS8K9Tz0ZfJV+VpI9vDlkvWk9Ac0DrUMdWeg6Csx1Dww qF66t6MH8Y3VQ1TxTL8bLH9huNY8S+3oirWXKGNZ0m+FYLK880S4SYfT0MduCgtF zH0M181mBnN8KGIbMX8vQa3eJkYf61uIIfJC54ltT9P32MBcRiHBV1RZj5E4pjU+ Euhu/WhPXYbsIeHnAByY =IkR+ -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
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-namejsp/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 extensioncss/extension mime-typetext/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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: JSP in Static Resources
Well, If we want to follow up that post , then we should belive that: Setting the mime type is not working for css So we should use other ways to solve it. Is that true?! ~Regards, ~~Alireza Fattahi From: André Warnier a...@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-namejsp/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 extensioncss/extension mime-typetext/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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
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 a...@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-namejsp/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 extensioncss/extension mime-typetext/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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: JSP in Static Resources
On Sun, 2013-07-14 at 23:28 +0200, André Warnier wrote: 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. Another drawback to generating the CSS files dynamically is that you'll have to do extra work to make them cacheable. But when served as static resources, the default servlet does a good job of this for you. If you don't take steps to make them cacheable, they'll be fetched every time on every page adding extra load on your server and the network. Is that true?! ~Regards, ~~Alireza Fattahi From: André Warnier a...@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-namejsp/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 extensioncss/extension mime-typetext/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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org signature.asc Description: This is a digitally signed message part
Re: JSP in Static Resources
On Sun, Jul 14, 2013 at 3:53 PM, Tim Watts t...@cliftonfarm.org wrote: If you don't take steps to make them cacheable, they'll be fetched every time on every page adding extra load on your server and the network. Which would be *the whole point* of having dynamically generated style files, eh? :-) -- Hassan Schroeder hassan.schroe...@gmail.com http://about.me/hassanschroeder twitter: @hassan - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: JSP in Static Resources
Hello Alireza, what exactly was wrong with putting contentType=text/css;charset=UTF-8 on top of your css-jsps? Actually each page should have content-type, so why not the css jsps? Leon On Sun, Jul 14, 2013 at 12:43 PM, Alireza Fattahi afatt...@yahoo.comwrote: Well, If we want to follow up that post , then we should belive that: Setting the mime type is not working for css So we should use other ways to solve it. Is that true?! ~Regards, ~~Alireza Fattahi From: André Warnier a...@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-namejsp/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 extensioncss/extension mime-typetext/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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: JSP in Static Resources
On Sun, 2013-07-14 at 16:27 -0700, Hassan Schroeder wrote: On Sun, Jul 14, 2013 at 3:53 PM, Tim Watts t...@cliftonfarm.org wrote: If you don't take steps to make them cacheable, they'll be fetched every time on every page adding extra load on your server and the network. Which would be *the whole point* of having dynamically generated style files, eh? :-) Well yes, but I think that misses the point. The OP needs to deliver exactly 1 of 2 CSS's to the user. And I would imagine that in the vast majority of cases each user wants the same one each time. So giving up cacheability adds no value to the system. signature.asc Description: This is a digitally signed message part
Re: JSP in Static Resources
On 7/13/2013 10:56 PM, Alireza Fattahi wrote: Guys please concentrate on the main issue !! I ask again: When you set jsp servlet to process the css files by adding: servlet-mapping servlet-namejsp/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 extensioncss/extension mime-typetext/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 For Tomcat 6, using the contentType attribute of the page directive doesn't seem all that objectionable to me. response.setContentType() could also be used. For Tomcat 7, I agree that Konstantin Kolinko provided a very straightforward solution in an earlier post. If I remember correctly, he also pointed out that MIME mappings in web.xml are only used for static content. In addition, if the dynamically generated CSS is only used to import static CSS files, you might consider generating link elements in the HTML document instead. Assuming the HTML is dynamically generated, this would eliminate the caching problem Tim Watts pointed out and I believe would provide better performance on the client side. -Terence Bandoian - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
JSP in Static Resources
Hi, I want to add some jsp code in to my site.css. So, as this is a static resource I add below to my web.xml and ask tomcat to compile it as a jsp. servlet-mapping servlet-namejsp/servlet-name url-pattern*.css/url-pattern /servlet-mapping When I view the site in firefox it shows an error which says: [11:46:41.547] The stylesheet site.css was not loaded because its MIME type, text/html, is not text/css. @ chrome://fdm_ffext/content/fdm_brcache.js:86 I have added below to web.xml mime-mapping extensioncss/extension mime-typetext/css/mime-type /mime-mapping It did not helped. The site pages link to css as below: link href=/styles/site.css rel=stylesheet type=text/css / When I remove the servlet mapping and mime-mapping everything works fine. So I believe the mime type is not set correctly for css files. Any comments ?! ~Regards, ~~Alireza Fattahi
Re: JSP in Static Resources
Alireza Fattahi wrote: Hi, I want to add some jsp code in to my site.css. Maybe it is just me, but that does not seem to make any sense. Usually, it would be the other way around. Can you explain why you want to do this ? The idea of JSP is to have Java code which in the end produces a HTML page which is sent to the browser. The JSP is compiled into a servlet, which is executed when the browser calls that JSP page. The servlet produces HTML, which is sent the browser. The HTML page may contain links to CSS stylesheets, Javascript libraries etc. The browser retrieves these directly, as static objects, when it finds a link in the HTML. A CSS stylesheet is meant to provide instructions to the browser, about how to /render/ (display nicely) the final product, which is the HTML page (produced by the JSP/servlet). I cannot really imagine a scenario in which having Java code in there would make any sense. At the very least, that would make the later maintenance of that application hopelessly confusing. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: JSP in Static Resources
Hi, My situation is this: The site which i work should work in RTL and LTR modes ( I am using YAML for layout) The site.css should have this for LTR: @import url(../yaml/navigation/hlist.css); @import url(../yaml/forms/gray-theme.css); @import url(../yaml/screen/typography.css); @import url(../yaml/screen/screen-FULLPAGE-layout.css); for RTL it must have @import url(../../yaml/add-ons/rtl-support/core/base-rtl.css); @import url(../../yaml/add-ons/rtl-support/navigation/hlist-rtl.css); @import url(../../yaml/add-ons/rtl-support/forms/gray-theme-rtl.css); So I want to path a parameter to CSS and do some thing like this: http://www.mysite.com/site.css?direction=rtl and in the CSS @import url(../../yaml/add-ons/rtl-support/core/base-%=request.getParameter(direction)%.css); I donot want to to use if parameters in the jsp and do some thing like this: if request.getParameter(direction)=RTL { link href=styles/site-rtl.css rel=stylesheet type=text/css / } else{ link href=styles/site-ltr.css rel=stylesheet type=text/css / } The problem is that, although you set the mime type of css to text/css in web.xml. it does not take effect. I just find a bad work around which you must put %@page contentType=text/css %in top of all css files ~Regards, ~~Alireza Fattahi From: André Warnier a...@ice-sa.com To: Tomcat Users List users@tomcat.apache.org Sent: Saturday, 13 July 2013, 14:21 Subject: Re: JSP in Static Resources Alireza Fattahi wrote: Hi, I want to add some jsp code in to my site.css. Maybe it is just me, but that does not seem to make any sense. Usually, it would be the other way around. Can you explain why you want to do this ? The idea of JSP is to have Java code which in the end produces a HTML page which is sent to the browser. The JSP is compiled into a servlet, which is executed when the browser calls that JSP page. The servlet produces HTML, which is sent the browser. The HTML page may contain links to CSS stylesheets, Javascript libraries etc. The browser retrieves these directly, as static objects, when it finds a link in the HTML. A CSS stylesheet is meant to provide instructions to the browser, about how to /render/ (display nicely) the final product, which is the HTML page (produced by the JSP/servlet). I cannot really imagine a scenario in which having Java code in there would make any sense. At the very least, that would make the later maintenance of that application hopelessly confusing. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: JSP in Static Resources
2013/7/13 Alireza Fattahi afatt...@yahoo.com: Hi, My situation is this: The site which i work should work in RTL and LTR modes ( I am using YAML for layout) The site.css should have this for LTR: @import url(../yaml/navigation/hlist.css); @import url(../yaml/forms/gray-theme.css); @import url(../yaml/screen/typography.css); @import url(../yaml/screen/screen-FULLPAGE-layout.css); for RTL it must have @import url(../../yaml/add-ons/rtl-support/core/base-rtl.css); @import url(../../yaml/add-ons/rtl-support/navigation/hlist-rtl.css); @import url(../../yaml/add-ons/rtl-support/forms/gray-theme-rtl.css); So I want to path a parameter to CSS and do some thing like this: http://www.mysite.com/site.css?direction=rtl and in the CSS @import url(../../yaml/add-ons/rtl-support/core/base-%=request.getParameter(direction)%.css); I donot want to to use if parameters in the jsp and do some thing like this: if request.getParameter(direction)=RTL { link href=styles/site-rtl.css rel=stylesheet type=text/css / } else{ link href=styles/site-ltr.css rel=stylesheet type=text/css / } The problem is that, although you set the mime type of css to text/css in web.xml. it does not take effect. I just find a bad work around which you must put %@page contentType=text/css %in top of all css files 1. jsp-config jsp-property-group url-pattern*.css/url-pattern default-content-typetext/css/default-content-type /jsp-property-group /jsp-config Adding above to your WEB-INF/web.xml should both implicitly map your *.css files to a JSP servlet (no explicit servlet-mapping is needed) and set default content-type for them. 2. mime-mapping is useless here. It is used when serving static resources (be DefaultServlet) only. Moreover, such mapping is already present in conf/web.xml (which provides site-wide defaults). That is if you are using 7.0.42. You have not mentioned your version of Tomcat. 3. Top-posting is bad. http://tomcat.apache.org/lists.html#tomcat-users - 6. Best regards, Konstantin Kolinko - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: JSP in Static Resources
2013/7/13 Alireza Fattahi afatt...@yahoo.com: Hi, I copied below in my web.xml jsp-config jsp-property-group url-pattern*.css/url-pattern default-content-typetext/css/default-content-type /jsp-property-group /jsp-config It did not helped ?! Is it a config for tomcat 7. I am using tomcat 6. The eclipse says that default-content-type is invalid. Yes, it is from JSP 2.2 which requires Servlet 3.0 / Tomcat 7. For Tomcat 6 maybe you could make use of include-prelude element, though it is a bit more work. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: JSP in Static Resources
Alireza Fattahi wrote: Hi, My situation is this: The site which i work should work in RTL and LTR modes ( I am using YAML for layout) The site.css should have this for LTR: @import url(../yaml/navigation/hlist.css); @import url(../yaml/forms/gray-theme.css); @import url(../yaml/screen/typography.css); @import url(../yaml/screen/screen-FULLPAGE-layout.css); for RTL it must have @import url(../../yaml/add-ons/rtl-support/core/base-rtl.css); @import url(../../yaml/add-ons/rtl-support/navigation/hlist-rtl.css); @import url(../../yaml/add-ons/rtl-support/forms/gray-theme-rtl.css); So I want to path a parameter to CSS and do some thing like this: http://www.mysite.com/site.css?direction=rtl and in the CSS @import url(../../yaml/add-ons/rtl-support/core/base-%=request.getParameter(direction)%.css); I donot want to to use if parameters in the jsp and do some thing like this: if request.getParameter(direction)=RTL { link href=styles/site-rtl.css rel=stylesheet type=text/css / } else{ link href=styles/site-ltr.css rel=stylesheet type=text/css / } I agree that the above does not look very elegant. I don't really know JSP syntax, but can't you do something like link href=styles/site-% request.getParameter(direction) %.css rel=stylesheet type=text/css / I am looking at this from a naive point of view, and thinking about the poor guys who are going to have to debug one of these pages in 12 month's time, and who'll have to figure out that the .css stylesheets on that site are not, as usual, plain CSS files usable everywhere, but have to be processed like JSP files. (Also, if you ever have to give this to a graphic guy, he may have some trouble working with this). I guess that there is nothing wrong in the /principle/ of having a CSS file being compiled into a servlet generating a CSS document, but somehow it does not seem the most straightforward thing to do. The problem is that, although you set the mime type of css to text/css in web.xml. it does not take effect. I just find a bad work around which you must put %@page contentType=text/css %in top of all css files ~Regards, ~~Alireza Fattahi From: André Warnier a...@ice-sa.com To: Tomcat Users List users@tomcat.apache.org Sent: Saturday, 13 July 2013, 14:21 Subject: Re: JSP in Static Resources Alireza Fattahi wrote: Hi, I want to add some jsp code in to my site.css. Maybe it is just me, but that does not seem to make any sense. Usually, it would be the other way around. Can you explain why you want to do this ? The idea of JSP is to have Java code which in the end produces a HTML page which is sent to the browser. The JSP is compiled into a servlet, which is executed when the browser calls that JSP page. The servlet produces HTML, which is sent the browser. The HTML page may contain links to CSS stylesheets, Javascript libraries etc. The browser retrieves these directly, as static objects, when it finds a link in the HTML. A CSS stylesheet is meant to provide instructions to the browser, about how to /render/ (display nicely) the final product, which is the HTML page (produced by the JSP/servlet). I cannot really imagine a scenario in which having Java code in there would make any sense. At the very least, that would make the later maintenance of that application hopelessly confusing. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: JSP in Static Resources
On 7/13/2013 9:29 AM, André Warnier wrote: Alireza Fattahi wrote: Hi, My situation is this: The site which i work should work in RTL and LTR modes ( I am using YAML for layout) The site.css should have this for LTR: @import url(../yaml/navigation/hlist.css); @import url(../yaml/forms/gray-theme.css); @import url(../yaml/screen/typography.css); @import url(../yaml/screen/screen-FULLPAGE-layout.css); for RTL it must have @import url(../../yaml/add-ons/rtl-support/core/base-rtl.css); @import url(../../yaml/add-ons/rtl-support/navigation/hlist-rtl.css); @import url(../../yaml/add-ons/rtl-support/forms/gray-theme-rtl.css); So I want to path a parameter to CSS and do some thing like this: http://www.mysite.com/site.css?direction=rtl and in the CSS @import url(../../yaml/add-ons/rtl-support/core/base-%=request.getParameter(direction)%.css); I donot want to to use if parameters in the jsp and do some thing like this: if request.getParameter(direction)=RTL { link href=styles/site-rtl.css rel=stylesheet type=text/css / } else{ link href=styles/site-ltr.css rel=stylesheet type=text/css / } I agree that the above does not look very elegant. I don't really know JSP syntax, but can't you do something like link href=styles/site-% request.getParameter(direction) %.css rel=stylesheet type=text/css / I am looking at this from a naive point of view, and thinking about the poor guys who are going to have to debug one of these pages in 12 month's time, and who'll have to figure out that the .css stylesheets on that site are not, as usual, plain CSS files usable everywhere, but have to be processed like JSP files. (Also, if you ever have to give this to a graphic guy, he may have some trouble working with this). I guess that there is nothing wrong in the /principle/ of having a CSS file being compiled into a servlet generating a CSS document, but somehow it does not seem the most straightforward thing to do. The problem is that, although you set the mime type of css to text/css in web.xml. it does not take effect. I just find a bad work around which you must put %@page contentType=text/css %in top of all css files ~Regards, ~~Alireza Fattahi From: André Warnier a...@ice-sa.com To: Tomcat Users List users@tomcat.apache.org Sent: Saturday, 13 July 2013, 14:21 Subject: Re: JSP in Static Resources Alireza Fattahi wrote: Hi, I want to add some jsp code in to my site.css. Maybe it is just me, but that does not seem to make any sense. Usually, it would be the other way around. Can you explain why you want to do this ? The idea of JSP is to have Java code which in the end produces a HTML page which is sent to the browser. The JSP is compiled into a servlet, which is executed when the browser calls that JSP page. The servlet produces HTML, which is sent the browser. The HTML page may contain links to CSS stylesheets, Javascript libraries etc. The browser retrieves these directly, as static objects, when it finds a link in the HTML. A CSS stylesheet is meant to provide instructions to the browser, about how to /render/ (display nicely) the final product, which is the HTML page (produced by the JSP/servlet). I cannot really imagine a scenario in which having Java code in there would make any sense. At the very least, that would make the later maintenance of that application hopelessly confusing. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org JSP files may be used to generate any type of content dynamically - HTML, JSON, CSS... It's up to the programmer to make their usage clear through the use of conventions, documentation, etc. -Terence Bandoian - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: JSP in Static Resources
Terence M. Bandoian wrote: On 7/13/2013 9:29 AM, André Warnier wrote: Alireza Fattahi wrote: Hi, My situation is this: The site which i work should work in RTL and LTR modes ( I am using YAML for layout) The site.css should have this for LTR: @import url(../yaml/navigation/hlist.css); @import url(../yaml/forms/gray-theme.css); @import url(../yaml/screen/typography.css); @import url(../yaml/screen/screen-FULLPAGE-layout.css); for RTL it must have @import url(../../yaml/add-ons/rtl-support/core/base-rtl.css); @import url(../../yaml/add-ons/rtl-support/navigation/hlist-rtl.css); @import url(../../yaml/add-ons/rtl-support/forms/gray-theme-rtl.css); So I want to path a parameter to CSS and do some thing like this: http://www.mysite.com/site.css?direction=rtl and in the CSS @import url(../../yaml/add-ons/rtl-support/core/base-%=request.getParameter(direction)%.css); I donot want to to use if parameters in the jsp and do some thing like this: if request.getParameter(direction)=RTL { link href=styles/site-rtl.css rel=stylesheet type=text/css / } else{ link href=styles/site-ltr.css rel=stylesheet type=text/css / } I agree that the above does not look very elegant. I don't really know JSP syntax, but can't you do something like link href=styles/site-% request.getParameter(direction) %.css rel=stylesheet type=text/css / I am looking at this from a naive point of view, and thinking about the poor guys who are going to have to debug one of these pages in 12 month's time, and who'll have to figure out that the .css stylesheets on that site are not, as usual, plain CSS files usable everywhere, but have to be processed like JSP files. (Also, if you ever have to give this to a graphic guy, he may have some trouble working with this). I guess that there is nothing wrong in the /principle/ of having a CSS file being compiled into a servlet generating a CSS document, but somehow it does not seem the most straightforward thing to do. The problem is that, although you set the mime type of css to text/css in web.xml. it does not take effect. I just find a bad work around which you must put %@page contentType=text/css %in top of all css files ~Regards, ~~Alireza Fattahi From: André Warnier a...@ice-sa.com To: Tomcat Users List users@tomcat.apache.org Sent: Saturday, 13 July 2013, 14:21 Subject: Re: JSP in Static Resources Alireza Fattahi wrote: Hi, I want to add some jsp code in to my site.css. Maybe it is just me, but that does not seem to make any sense. Usually, it would be the other way around. Can you explain why you want to do this ? The idea of JSP is to have Java code which in the end produces a HTML page which is sent to the browser. The JSP is compiled into a servlet, which is executed when the browser calls that JSP page. The servlet produces HTML, which is sent the browser. The HTML page may contain links to CSS stylesheets, Javascript libraries etc. The browser retrieves these directly, as static objects, when it finds a link in the HTML. A CSS stylesheet is meant to provide instructions to the browser, about how to /render/ (display nicely) the final product, which is the HTML page (produced by the JSP/servlet). I cannot really imagine a scenario in which having Java code in there would make any sense. At the very least, that would make the later maintenance of that application hopelessly confusing. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org JSP files may be used to generate any type of content dynamically - HTML, JSON, CSS... It's up to the programmer to make their usage clear through the use of conventions, documentation, etc. Yes, but experience says that they don't. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: JSP in Static Resources
Guys please concentrate on the main issue !! I ask again: When you set jsp servlet to process the css files by adding: servlet-mapping servlet-namejsp/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 extensioncss/extension mime-typetext/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