How can I reference an external CSS file from a Servlet?

Alessandro A. Garbagnati

[I have I servlet that generates a HTML page and I want to use a CSS file (named senior.css), so I wrote a statement like that:

out.print(" <link rel='stylesheet' type='text/css' href='senior.css'>")

The statement is perfect, but remember that it is parsed by the browser so the file should reside in a directory that is accessible to the browser.

I suggest you to put the CSS file in the rood of your context and have that statement point there. That's what I normally do.

[That way, no matter where your page is located, it can find it at the root level if it's called "/senior.css" or "/foowebapp/senior.css". -Alex]