• Post Reply Bookmark Topic Watch Topic
  • New Topic

css link problem

 
Vinnie Jenks
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having an issue trying to figure out why my CSS stylesheet won't work in my JSP.

I've created a .css file and added a single class (.textTitle) as a test case. I apply the style using the class attribute of the html tag but the style doesn't appear to do anything.

I'm using RequestDispatcher to pass the request to the JSP and the page is using an XHTML DTD, which I'm not sure is causing the issue or not (I'm not familiar w/ the potential css implications using XHTML vs plain ol' HTML.) I pulled out the xml/xhtml specific tags and removed the DOCTYPE tag altogether and it didn't make a difference.

Here's a snippet from the JSP:



Here's a snippet from employee_directory.css:



I'm *quite* sure I'm calling the css file from the correct directory...as a test I used a jsp:include using the same path for the css file and the contents appeared in the page...so I must have that much right! :roll:

So...not sure what I should do...any ideas?

Thanks!

-v
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm *quite* sure I'm calling the css file from the correct directory...as a test I used a jsp:include using the same path for the css file and the contents appeared in the page...so I must have that much right!


Despite your assuredness, your <jsp:include> test is invalid as that is a server-side mechanism that uses context-relative addressing. The <link> tag is a client-side mechanism that needs a server-relative reference.

Your best best is to always use server-relative urls in such client-side elements, be they <link>, <script> or <img> tags.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!