GeeCON Prague 2014*
The moose likes HTML, CSS and JavaScript and the fly likes Including the web context in CSS file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Including the web context in CSS file" Watch "Including the web context in CSS file" New topic
Author

Including the web context in CSS file

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

Hi.
Consider a css rule like :

Is there a way to include the web context path in the previous line (not hard coding it)?
Please not the the previous rule is in a standalone CSS file, so I don't think it is possible to have: ${pageContext.request.contextPath}/images/ul.gif
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You could have it replaced at build time. other than that you would have to include it on your jsp page.

Eric
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

Sorry but I didn't understand
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61306
    
  66

There is no run-time substitution mechanism for css files.

What you have described is a real problem for deploying context-independent css files. Most people just hard-code the path, either in the source file, or during the build.
[ June 01, 2007: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
Shouldn't this work?
In your jsp:


And then in your file /stylesheets/style.jsp (stylesheet):


[ June 06, 2007: Message edited by: Dom Lassy ]
[ June 06, 2007: Message edited by: Dom Lassy ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Including the web context in CSS file