How to import a CSS file in JSP?

ILikeTurtles picture ILikeTurtles · May 31, 2013 · Viewed 59.6k times · Source
<%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?

Answer

Jaymelson Galang picture Jaymelson Galang · Jun 2, 2013

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