wood burning stoves 2.0*
The moose likes JSF and the fly likes login page - css file loads but images don't Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "login page - css file loads but images don Watch "login page - css file loads but images don New topic
Author

login page - css file loads but images don't

Adam Kronicki
Ranch Hand

Joined: Sep 01, 2009
Posts: 68
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:
<img src="res/img/back.png">
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?
Mark Reyes
Ranch Hand

Joined: Jul 09, 2007
Posts: 426
Maybe firebug can help you.

Have you tried removing the ../ in your css file?

As far as I know, security constraints are laid up on the protected resource and not on this files. NOt sure though about your case.


Sean Clark ---> I love this place!!!
Me ------> I definitely love this place!!!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18666
    
    8

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.
Adam Kronicki
Ranch Hand

Joined: Sep 01, 2009
Posts: 68
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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: login page - css file loads but images don't