permaculture playing cards
The moose likes JSP and the fly likes How to get Cascading Style Sheets with JSP/Tomcat Working? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to get Cascading Style Sheets with JSP/Tomcat Working?" Watch "How to get Cascading Style Sheets with JSP/Tomcat Working?" New topic

How to get Cascading Style Sheets with JSP/Tomcat Working?

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1130
Can anyone tell me if I can get Tomcat to use cascading style sheets?
I have a .css file in the root of my production folder and I've tried referencing the .css file with and without a leading "/", but neither works.
Thanks ion adance for anyone's help in this area.
-- Mike
Phil Chuang
Ranch Hand

Joined: Feb 15, 2003
Posts: 251
It shouldn't be tomcat that is the issue. If the CSS is valid, and referenced correctly, then your browser will take care of loading the CSS. If you don't see it working on a page, check the CSS link, and then check the CSS file for the correct syntax.
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1130
I did this already, but I must have missed something.
Thank you for your reply.
-- Mike
David Hibbs
Ranch Hand

Joined: Dec 19, 2002
Posts: 374
As has been said, this is not specifically a Tomcat issue. Do a view source and check your css location. Copy it into your browser URL bar. Can you load it? Probably not...
Define "in the root of my production folder" -- where is this in relation to your page trying to load it? Where is the context root looking?
Something else to check are that the file is readable by the id starting Tomcat.
Also double check that your file is where you think it is... I had this exact problem today--dropped a file in the parent directory instead of where I thought I put it.

"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The team, Newsletter 039.
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
i have faced the same problem.. Directory names and stylesheet name of ur css file should be case sensitive ..check it out..they are the culprit..
my css path is
<link rel="stylesheet" type="text/css" href="/raj/stylesheet/Style.css">
raj = context path
stylesheet = directory for keeping all my css
Style.css = name of css file
first i kept the css file name as style.css and it was not working..make all cross wll surly work
all the best

SCJP, SCWCD, SCBCD, Oracle Certified Professional (SQL n PL/SQL)
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1130
Thanks for all the great replies.
The thing Tomcat didn't appear to like was the "\" leading back to the site root.
Once I either removed the leading backslash or used ..\ notation, things worked out fine.
One note which I don't know is meaningful relative to the CSS problems I was having is that I used Dreamweaver MX for a lot of the HTML grunt work.
Thanks again for all the great info and replies!
-- Mike
Sylvia Allen

Joined: Apr 02, 2001
Posts: 18
Dreamweaver is tempting to use because of how easily you can get great HTML effects with it, but it makes a mess of the HTML code. If you use Dreamweaver, be prepared to go in and clean up your HTML afterward, for exactly the kind of reason you're talking about. The other thing you can do is use Dreamweaver to get the effect you want, then go in to the code and see how it did it, and then make your real page with nice, clean HTML.

Sylvia Allen<br />
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

If you prep correctly and set Dreamweaver up correctly, it does not mess up your HTML code. The best thing to do with Dreamweaver is create a local test site that is a mirror of your production site. Then all your links will be relative to the appropriate location and you wont run into "/" problems.
Sorry to highjack, just had to defend Dreamweaver a bit. It's the only reason I use Windows.

GenRocket - Experts at Building Test Data
I agree. Here's the link:
subject: How to get Cascading Style Sheets with JSP/Tomcat Working?
jQuery in Action, 3rd edition