Does anyone know why I can't get an external style sheet work work when using JSP files? Putting a link in the doc head like I would for an HTML or PHP file does not work. The style sheet is in the exact same directory as the JSP files and I cannot get it to work. I think I have tried about everything that has been suggested on the web with no luck.
If I create an HTML doc in the same directory as the JSP files, and add the below line in the document head, it works fine. Doing the same thing with a JSP file does nothing.
You must provide a complete path to the page including the context. Using the style above will insure that it works even on different servers with different contexts. Of course your path will vary from my example; that's up to you to sort out.
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
Raymond Gillespie wrote:
The JSP files are in the WebContent directory and that is also where the CSS file sheet is as well.
You're running inside an IDE aren't you? That complicates things. It's been suggested elsewhere that running outside the IDE is the best way to make sure things work without the cruft and complications that an IDE adds (like a bogus WebContent folder).
In any case, you need to find out what the folder structure the IDE expects and to add that.
For now just use the address bar of the browser to find the right URL rather than screwing around inside the JSP. When you find the URL that lets the browser display the CSS file as text, you'll know you have the right URL.