You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mike Quilleash <mi...@subexazure.com> on 2007/03/27 15:21:38 UTC

Paths in CSS files

Hi all,
 
I have a question about accessing resources from within CSS files,
images mainly.  Take the following CSS snippet.
 
.bt {
 background:url(/image/box.png) no-repeat 100% 0;
 margin:0 0 0 18px;
 height:17px;
 }

Particularly the url "/image/box.png".  Potentially my Tomcat web
application may be run with a context path so "/image/" becomes
"/contextpath/image" and all the CSS breaks.  Is there a way round this?
Or should I be placing the urls somewhere else?
 
Thanks.
 
Mike.
 

 This e-mail is bound by the terms and conditions described at http://www.subexazure.com/mail-disclaimer.html


Re: Paths in CSS files

Posted by Darren <da...@googlemail.com>.
Something I've done before is rename my css files to jsp and use $ 
{pageContext.request.contextPath} within them.

<%@page contentType="text/css"%>
<%@page pageEncoding="UTF-8"%>

#header {
     margin: 0px 0px 15px 0px;
     height: 100px;
     background: url(${pageContext.request.contextPath}/image/ 
logo.gif) top
}


On 27 Mar 2007, at 14:21, Mike Quilleash wrote:

> Hi all,
>
> I have a question about accessing resources from within CSS files,
> images mainly.  Take the following CSS snippet.
>
> .bt {
>  background:url(/image/box.png) no-repeat 100% 0;
>  margin:0 0 0 18px;
>  height:17px;
>  }
>
> Particularly the url "/image/box.png".  Potentially my Tomcat web
> application may be run with a context path so "/image/" becomes
> "/contextpath/image" and all the CSS breaks.  Is there a way round  
> this?
> Or should I be placing the urls somewhere else?
>
> Thanks.
>
> Mike.
>
>
>  This e-mail is bound by the terms and conditions described at  
> http://www.subexazure.com/mail-disclaimer.html
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Paths in CSS files

Posted by Hassan Schroeder <ha...@gmail.com>.
On 3/27/07, Mike Quilleash <mi...@subexazure.com> wrote:

> I have a question about accessing resources from within CSS files,

> Particularly the url "/image/box.png".  Potentially my Tomcat web
> application may be run with a context path so "/image/" becomes
> "/contextpath/image" and all the CSS breaks.  Is there a way round this?

background:url(${pageContext.request.contextPath}/image/box.png)
no-repeat 100% 0;

Parse those files as JSPs and the above will take care of it :-)

HTH,
-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org