Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a website project in Eclipse using servlets which is running on Tomcat. In one of the servlets I reference an external stylesheet as such:

<link rel="stylesheet" type="text/css" href="style.css" />

Where would I put this style.css for it to work? I have tried almost every folder in the project directory and in the site directory under Tomcat and it still won't work.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

I found the solution. As silviud said, the style.css file should go in the root of the application, in this case: $TOMCAT_HOME/wtpwebapps/ProjectName. To get it there it should go in the WebContent folder in eclipse: $PROJECT_HOME/WebContent.

The reason I wasn't seeing the stylesheet was because I had the main servlet registered for "/" which means that when I requested /style.css, it got the servlet instead.

share|improve this answer

isn't that going to be served as from where you serve the html file ?! can you try to have the link changed to "/style.css" and see where is configured the root for your application.

for example if your application is into $TOMCAT_HOME/webapps/my_application you need to put the file into $TOMCAT_HOME/webapps/my_application/style.css.

look into the $TOMCAT_HOME/webapps/my_application/WEB-INF/web.xml on how is configured the servlet for your application.

s

ps: my example is kind of bad because java uses different 'standards' to serve static files.

share|improve this answer
    
I don't have an html file, I am using a servlet. It looks like it needs to go in $TOMCAT_HOME/wtpwebapps/ProjectName, but the problem is where do I put it in eclipse to make it go there? –  DanielGibbs Dec 20 '10 at 21:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.