In external style sheets of my current JSF project, there are hard-coded links to external resources like
.someId { background-image:url(/context/resources/images/example.jpg); }
In the JSF xhtml documents, I could use EL expressions like ${request.contextPath} but how can EL processing be applied to CSS files?
(Related: How can I embed an CSS background image link with JSF?)
Hard-coding of context paths has a disadvantage: the context path – /context in the example – of a web application can be changed at deploy time by modifying the web.xml (or by renaming the web application archive file if no context is specified in web.xml), but links to resources in the CSS files would still point to the unchanged hard coded context, and cause resource not found errors.
I put the CSS images always in a subfolder of the CSS folder. E.g.
This way you just end up like
Yes, they are resolved relative to the URL of the CSS file itself, not to the main JSF/HTML page.