tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrick Flaherty <pflah...@rampageinc.com>
Subject Re: Links in CSS vs JSPs
Date Tue, 20 Sep 2011 15:15:47 GMT

On Sep 20, 2011, at 9:09 AM, Konstantin Kolinko wrote:

> 2011/9/18 Patrick Flaherty <pflahrty@rampageinc.com>
>>
>> Hi,
>>
>> We have just changed the way we deploy our webapp. We previously  
>> were putting our app into the ROOT folder under webapps , not good  
>> I know.
>> We now package the app as a war file called myapp.war and place it  
>> into the webapps folder where it explodes into a folder called  
>> myapp. Everything
>> works except for one thing. Our app has the option to let the user  
>> change the look & feel of the web app using predefined skins which  
>> we store in a
>> folder called templates inside the myapp folder. Inside the  
>> templates folder are the folders that represent all the various  
>> skins (skin1, skin2 etc ..).
>> These skin folders contain all the jsps, the css file and images  
>> that represent the content of each skin.
>>
>> Here’s the problem which is easily remedied but I want to know why.  
>> Let me explain. All the skins work except image references in the  
>> style sheet (css)
>> cannot be found. Yet images referenced in the jsps are found ! The  
>> references to the images begin with the url /templates/skin1/images/ 
>> image1.png in both the
>> css case and the jsp case. Now to fix the problem I change the url  
>> in the style sheet by adding my app name in front (i.e. /myapp/ 
>> templates/skin1/images/image1.png)
>> and this fixes the problem.
>>
>> I have no problem with changing this and it’s even logical. I’m  
>> just trying to understand why this only has presented a problem  
>> with links in the css and not the jsps.
>> In firebug the reference to images already have my app name  
>> prepended to the images automatically. (i.e. /myapp/templates/skin1/ 
>> images/image2.png) YET the jsps’
>> references only begin the url /templates/skin1/images/image1.png  
>> (no prepended app name)
>
> 1. Isn't it "templates/skin1/images/image1.png" in JSPs?
> (Without leading "/", thus relative to the current page and not to the
> root of the web server).

No, it's actually "templates/$(skin)/images/image1.png" in the JSPs.
>
> How do you print those links in JSPs? (Hard-coded, or you are using
> some tag or API calls?)
Tags
>
> 2. How do you write the URLs in your css files?

Hard coded.
/templates/skin1/images/image1.png    If I try removing the / prefix  
then the path in the browser becomes /appname/templates/skin1/css/ 
templates/skin1/images/image1.png

>
> Read the official CSS spec from W3C on how relative links in css files
> are resolved. In CSS 2.1 it is in ch.4.3.4. Citing:
> "For CSS style sheets, the base URI is that
> of the style sheet, not that of the source document."

Interesting, I can try a relative path starting from the location of  
CSS ?
I read up.
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> 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
View raw message