Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B056370C3 for ; Tue, 20 Sep 2011 13:10:11 +0000 (UTC) Received: (qmail 29223 invoked by uid 500); 20 Sep 2011 13:10:08 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 29049 invoked by uid 500); 20 Sep 2011 13:10:07 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 29040 invoked by uid 99); 20 Sep 2011 13:10:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Sep 2011 13:10:07 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of knst.kolinko@gmail.com designates 209.85.216.173 as permitted sender) Received: from [209.85.216.173] (HELO mail-qy0-f173.google.com) (209.85.216.173) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Sep 2011 13:10:01 +0000 Received: by qyc1 with SMTP id 1so15792417qyc.18 for ; Tue, 20 Sep 2011 06:09:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=aGiZb6A8SP82KdsV/vYhnilZJ5RO7PC0msInnsC5Xww=; b=KEOkX/ErriUUTvN3ylTU2IHaaita82QRgBzw9aHZKXECVwtSOaqtrgDsz0YmaYFbeD d7dQSvcm3fXDRO7Fu+5XuAsUcttDhMkwKYdReg7OQepNZqFTK+9P+as6fFH7fqy+b1Dx Arq0BujWoS+0bEj3taYnsQav7VwISNTHnNqUM= MIME-Version: 1.0 Received: by 10.52.178.137 with SMTP id cy9mr664501vdc.340.1316524180508; Tue, 20 Sep 2011 06:09:40 -0700 (PDT) Received: by 10.52.111.40 with HTTP; Tue, 20 Sep 2011 06:09:40 -0700 (PDT) In-Reply-To: References: Date: Tue, 20 Sep 2011 17:09:40 +0400 Message-ID: Subject: Re: Links in CSS vs JSPs From: Konstantin Kolinko To: Tomcat Users List Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org 2011/9/18 Patrick Flaherty > > Hi, > > We have just changed the way we deploy our webapp. We previously were put= ting our app into the ROOT folder under webapps=A0, not good I know. > We now package the app as a war file called=A0myapp.war=A0and place it in= to the webapps folder where it explodes into a folder called=A0myapp. Every= thing > 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=A0templates=A0inside the=A0myapp=A0folder. Inside the=A0tem= plates folder=A0are the folders that represent all the various skins (skin1= , skin2 etc ..). > These skin folders contain all the jsps, the css file and images that rep= resent the content of each skin. > > Here=92s the problem which is easily remedied but I want to know why. Let= me explain. All the skins work except=A0image references in the style shee= t (css) > cannot be found. Yet images referenced in the jsps are found ! The refere= nces 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.=A0/myapp/templates/skin1/= images/image1.png) > and this fixes the problem. > > I have no problem with changing this and it=92s even logical. I=92m just = trying to understand why this only has presented a problem with links in th= e css and not the jsps. > In firebug the reference to images already have=A0my app name=A0prepended= to the images automatically. (i.e.=A0/myapp/templates/skin1/images/image2.= png) YET the jsps=92 > references only begin the url /templates/skin1/images/image1.png (no prep= ended 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). How do you print those links in JSPs? (Hard-coded, or you are using some tag or API calls?) 2. How do you write the URLs in your css files? 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." Best regards, Konstantin Kolinko --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org