css
.myStyle {
height: 10px;
background-image: url(../myImage.png);
}
jsp
<img class=myStyle src=<% imageurl != null ? imageurl: (bacground-image property from my css)%> >
Is there any way to achieve this?
I don’t want to hardcode the default url in my code, to allow change of default image by just changing the css property.
What you really want is a property file – for example like this http://www.easywayserver.com/blog/java-resourcebundle-properties-file-jsp/
and
Alternative if you must
https://stackoverflow.com/a/2104580/295783
May loop if the bgimage code fails to give a good image too