On Thu, 9 Jan 2003, Joe Barefoot wrote:

> Date: Thu, 9 Jan 2003 14:46:09 -0800
> From: Joe Barefoot <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: Struts Users Mailing List <[EMAIL PROTECTED]>
> Subject: RE: context relative image reference in a CSS file
>
> The simplest solution is to use a relative path:
> ul {
>  list-style-image: url(../images/li.gif);
> }
>
> If you have your CSS file in folder 'css' (for instance), with sibling
> folder 'images', this will work no matter what the app. context name is,
> in Tomcat at least (I assume other web servers resolve the same way
> though).
>

Just a minor note ... servers don't resolve relative URIs -- clients do.

However, as long as your browser obeys the CSS spec and resolves relative
URIs against the absolute URL of the stylesheet (not the source document),
then this technique should work fine.

> Second option:  If you're using ant to deploy, you could use tokens in
> your CSS files and have ant replace them during copy/deploy using a
> filter task--you can conditionally use different filter values for
> replacement depending on a deploy target property or something.  That's
> all I can think of.
>
> peace,
> Joe
>

Craig

> > -----Original Message-----
> > From: Justin Ashworth [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, January 09, 2003 2:38 PM
> > To: Struts Users Mailing List
> > Subject: Re: context relative image reference in a CSS file
> >
> >
> > Hi Dan,
> >
> > I just ran into this same issue today, and I hope that
> > somebody has a better
> > idea than what I ended up doing.  I changed the .css files to
> > .jsp and put
> > script tags around them and included them as JSPs.  This, of
> > course, gave me
> > access to taglibs which would let me prepend the context path
> > to the image.
> >
> > Your example would end up looking something like this:
> >
> > <%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
> > <style type="text/css">
> > ul {
> > list-style-image: url(<html-el:rewrite page="/images/li.gif"/>);
> > }
> > </style>
> >
> > This is all I was able to figure out.  Does anybody have any
> > better ideas?
> >
> > Thanks,
> >
> > Justin
> >
> >
> > ----- Original Message -----
> > From: "Dan Payne" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Thursday, January 09, 2003 5:31 PM
> > Subject: context relative image reference in a CSS file
> >
> >
> > > I recall seeing someone mention a project on sourceforge
> > that allowed one
> > to
> > > make context independent references to images from the
> > context root within
> > > CSS files. Anyone? Or perhaps another solution?
> > >
> > > I've got this entry in my stylesheet.css file:
> > >
> > > ul {
> > > list-style-image: url(/images/li.gif);
> > > }
> > >
> > > and it's causing one hell of a headache as the app is deployed on
> > different
> > > contexts. Any ideas?
> > >
> > > thanks...Dan
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to