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