Browser doesn't show dynamically generated CSS in JSP

61 views Asked by At

I'm writing simple web app which generates simple CSS file for user.

I've mapped servlet for writing CSS on specific tag, and depending of the user's session attributes, I use PrintWriter for generating CSS stylesheet.

Problem: Stylesheet doesn't have any effect. Chrone shows it was downloaded (inspect element -> network), but it doesn't have any effect on my htmlpage.

In html, CSS is defined by: <link href="stylesheet.css" rel="stylesheet" type='text/css'>.

1

There are 1 answers

1
BalusC On BEST ANSWER

That will happen if the response content type is (implicitly) set to something else than text/css. You can easily verify it in response headers section in HTTP traffic monitor.

Explicitly set it before writing any byte to the response body.

response.setContentType("text/css");
// ...