How to import a CSS file in JSP?

60,192

Solution 1

I think you want to include index.css file to jsp. try this

<jsp:include page="index.css"/>

or

<%@include file="/WEB-INF/include/header.jsp"%>

but i recommend to use tag in html

Solution 2

Neither PHP nor JSP have anything to do with CSS.

You can link the resulting HTML to a stylesheet the same way you would in any other HTML, using the <link> tag.

Share:
60,192
ILikeTurtles
Author by

ILikeTurtles

SOreadytohelp I like turtles.

Updated on July 23, 2020

Comments

  • ILikeTurtles
    ILikeTurtles almost 4 years
    <%String path = application.getRealPath("/");%>
    <%@page import="index.css" %>
    

    I am using String path as above to get the real path of my directory. I want to import index.css from the css folder.

    Is it possible in JSP to do something like <%@page import = path+"css/index.css"%> or is there an easier way to do this?

  • ILikeTurtles
    ILikeTurtles almost 11 years
    This is what I wanted. Just wanted to know how to include the CSS file in jsp using a jsp include. Thanks!
  • Koray Tugay
    Koray Tugay over 9 years
    Youtube link is dead.