Where should I place external stylesheets for servlets using Tomcat and Eclipse?

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.

Answer

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.

Attribution
Source : Link , Question Author : DanielGibbs , Answer Author : DanielGibbs

Leave a Comment