File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Mike London
Ranch Hand
Posts: 1158
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 251
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1158
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did this already, but I must have missed something.
Thank you for your reply.
-- Mike
 
David Hibbs
Ranch Hand
Posts: 374
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 checks..it wll surly work
all the best
raj
SCJP2
 
Mike London
Ranch Hand
Posts: 1158
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic