You are here: Home / Topics / How did I Setup bootstrap css in my Java EE project?

How did I Setup bootstrap css in my Java EE project?

Filed under: Java EE on 2024-03-30 20:48:24

During my setup of java EE project. I faced one problem. I was unable to include bootstrap css in my project. I tried many ways to do this.

<link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap.min.css"/>

But it was not being included in my webpages (.jsp pages) so i searched on google for resolving this problem and then i came to conclusion that

add two dependencies in pom.xml file these are

<dependency>
 <groupId>jakarta.servlet.jsp.jstl</groupId>
 <artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
 <version>3.0.0</version>
</dependency>
<dependency>
 <groupId>org.glassfish.web</groupId>
 <artifactId>jakarta.servlet.jsp.jstl</artifactId>
 <version>3.0.1</version>
</dependency>

 


then change your css link href :

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="contextPath" value="${pageContext.request.contextPath}" />
<link rel="stylesheet" href="${contextPath}/pages/assets/vendor/bootstrap/css/bootstrap.min.css">


This way you can add bootstrap css dynamically in all of your jsp pages.

About Author:
J
Java Developer     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.