How to access files from this hierarchy?
Tags: html,css,eclipse,jsp
Problem :
I need to access from the jsp files which are in WebContent/jsp folder, to the *.css file which is in WebContent/css.
And I've tried using link rel="stylesheet" type="text/css" href="../css/adminStyle.css"
. But, sometimes the *.css works and sometimes it doesn't.
Another thing is how do I access from a *.css file to an image in imgs folder. And I tried using background-image:url('../imgs/background.png');
The hierarchy is the following:
WebContent
css
|
+---> adminStyle.css
imgs
|
+---> background.png
jsp
|
+---> admin.jsp
Solution :
"sometimes the css works and sometimes not" looks like you it works for some url and doesn't work for some url. for this @rickz answer will work
href="${pageContext.request.contextPath}/css/adminStyle.css"
This will eliminate the possibility of breaking css import with regards of url
for second question "how do I access from a css file to an image in imgs folder"
background-image:url('../imgs/background.png');
because relative path of background image defined in css will start from the folder where your css file is.