0

When I am trying to access my JSP page, CSS and JS are not loading. I am using below syntax for the same:

<!DOCTYPE html>
<%@page import="java.util.ArrayList"%>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href=WebContent/CSS/example.css />
<link rel="stylesheet" type="text/css" href=WebContent/CSS/bootstrap.min.css />

<title>Example</title>
</head>
<body>
    <jsp:include page="header.jsp" />


    <jsp:include page="Footer.jsp" />
    <script src="WebContent/js/bootstrap.min.js"></script>
          <script src="WebContent/js/jquery.min.js"></script>   
</body>

My css is placed under WebContent -> CSS folder.

I already tried using context path using ${pageContext.request.contextPath}

I also tried using "" value in href tag, but of no use.

I am stuck in this issue from last two days... :( please help

8
  • Missing " for the href attribute of your slylesheets Commented Jun 26, 2014 at 7:03
  • Are you able to browse straight to the .css files anyway? http://localhost:12345/yourpath/WebContent/CSS/example.css Commented Jun 26, 2014 at 7:04
  • have u tried (href="../WebContent/CSS/example.css") Commented Jun 26, 2014 at 7:04
  • Small correction I am using below format for css: Commented Jun 26, 2014 at 7:04
  • Better to refer file from the root of your site, using "/" before anythong else Commented Jun 26, 2014 at 7:05

2 Answers 2

1
<!DOCTYPE html>
<%@page import="java.util.ArrayList"%>
<html lang="en">
<head>
    <link rel="stylesheet" type="text/css" href="CSS/example.css"/>
    <link rel="stylesheet" type="text/css" href="CSS/bootstrap.min.css"/>

    <title>Example</title>
</head>
<body>
<jsp:include page="header.jsp"/>


<jsp:include page="Footer.jsp"/>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.min.js"></script>
</body>
</html>
Sign up to request clarification or add additional context in comments.

Comments

0

instead of this :

<link rel="stylesheet" type="text/css" href=WebContent/CSS/example.css />
<link rel="stylesheet" type="text/css" href=WebContent/CSS/bootstrap.min.css />

use this :

<link rel="stylesheet" type="text/css" href="CSS/example.css" />
<link rel="stylesheet" type="text/css" href="CSS/bootstrap.min.css" />

Comments

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.