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.
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.
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.