cancel
Showing results for 
Search instead for 
Did you mean: 

How reference images in css

Former Member
0 Kudos

Hi Everybody,

how can i reference a image in css? Until now i used the following piece of code which only works if i put the css inside my jsp file. What could be the reason. When i put the css part in a seperate file the images are not referenced.

index.jsp:


<%	String mimeUrl = componentRequest.getWebResourcePath(); %>

<link rel="stylesheet" href='<%=mimeUrl+"/css/myStyle.css"%>' type="text/css" />

<ul class="glossymenu">
	<li><a href="http://www.dynamicdrive.com/style/"><b>CSS</b></a></li>
	<li><a href="http://www.dynamicdrive.com/forums/"><b>Forums</b></a></li>	
</ul>

myStyle.css:



<style>
.glossymenu{
	position: relative;
	padding: 0 0 0 34px;
	margin: 0 auto 0 auto;
	background: url(<%=mimeUrl%>/images/menub_bg.gif) repeat-x;	
	height: 46px;
	list-style: none;
}
....
</style>

regards,

Seed

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

because files ending with .css are usally not processed by the jsp processor - so <% .... %> stays in ans <% ... %> (just try to open the css in your browser)

one way is to rename your .css files to jsp or tell the application server to process .css files like .jsp files

regards

franz

Answers (0)