1

suppose I have an inline styling such as below inside a .JSP file:

<style>
.bg{
    background-color: <%=application.getAttribute("bgcolor").toString()%>
}
</style>

What if I want to make it an external .CSS file instead of using inline styling? I tested it and it doesn't work properly?

Many thanks!

1

1 Answer 1

2

The .jsp files are compiled by the container, so you have to write the you css class in .jsp file make sure the response content type is text/css and add the JSP file to your html like below.

<link rel="stylesheet" href="filename.jsp">
Sign up to request clarification or add additional context in comments.

2 Comments

Can I also use the include directive? Like say, I store all my internal styling in another file and instead of using <link href="something.css"> I use the include directive instead?
You can also do that but it only work in jsp files, but if you have some HTML include directive wont work..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.