1

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.

DanielGibbs
  • 573
  • 5
  • 13
  • 32

2 Answers2

1

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.

DanielGibbs
  • 573
  • 5
  • 13
  • 32
0

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.

silviud
  • 2,687
  • 2
  • 18
  • 19
  • 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