I am using form-based authentication in my JSF2 webapp on Tomcat. On the login page I use css styling. I learned from previous experience with JSF 1.2 that I need to work on the security constrains, so the page could access the css file on the login page. So I did and the css file is loaded properly. The problem is that the images that are used in the css classes (like background-image: url(../res/img/back.png); ) are not loaded. Surprisingly when I use simple img tag on my login site:
it works... So the images cannot be loaded only from the css file...
My security constrains are:
This didn't happen it JSF 1.2 Why I the images cannot be loaded in the css file? How to fix this?
I believe that the URL in the CSS is treated as being relative to the URL from which the CSS file was loaded. And likewise the URL in the element is treated as being relative to the URL from which the HTML was loaded. So check out those URLs and see what the difference is.
Joined: Sep 01, 2009
I use the same css file and classes in further pages after logging in (.xhtml) and there everything works- the images are loaded. However it seems that for the login .html page the path buts be without 'resources' (the root catalog for css folder, img folder etc.), so now I must in fact have 2 css files which only differ in the img path (the new path doesn't work at .xhtml pages...). Quite annoying to be honest.