The moose likes JSF and the fly likes [SOLVED] CSS not being applied to my JSF? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "[SOLVED] CSS not being applied to my JSF?" Watch "[SOLVED] CSS not being applied to my JSF?" New topic

[SOLVED] CSS not being applied to my JSF?

Marco Di Baggio
Ranch Hand

Joined: Apr 11, 2009
Posts: 35
Hi everyone,

This is my first post, so I apologize in advance if this is a trivial question.

Simply put, I have created a JSF (WAR project) to test out some css concepts. I am attemping to include my css file in my JSF/JSP file but whenever I try to render the JPS page, the css rules are not being applied.
It would appear as though the project cannot find/apply the css file (at least this is what I believe is the case.

Here is some background information:

* JSF Project structure:
WebContent /
----> .jsp/jsf files etc
----> jpeps, images etc
----> FormStyle.css
----> faces-config.xml
----> geronimo-web.xml
----> web.xml
* Example.jsp -- to show how I reference the css file in my jsp's

* FormStyle.css

Again, this is a local project that I am running on my laptop to simply practice/refine some css priciples. So again this is run locally using:

1. WAS CE - websphere community edition
2. Eclipse IDE

Also it may be important to note that the JSF/JSP page is accessed through this URL path:


Please note the *faces* in the url path.

I hope that someone can confirm that this is simply a css referencing error?
Thanks again

Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Marco Di Baggio wrote:
<link rel=stylesheet" href="/Style/FormStyle.css" type="text/css">

You need to have project name there (i.e. /ProjectName/Style/FormStyle.css). This is a standard HTML tag, hence the root directory isn't your project directory but the domain root.

“Everything should be as simple as it is, but not simpler.” Albert Einstein
Marco Di Baggio
Ranch Hand

Joined: Apr 11, 2009
Posts: 35

Much appreciated. I resolved this issue by using:

Which appears to fill in the appropriate "project name" when reviewing the web page source code.
Post has been updated to "Resolved"
I agree. Here's the link:
subject: [SOLVED] CSS not being applied to my JSF?
jQuery in Action, 3rd edition