Sami Kobbi
Sami Kobbi

Reputation: 309

Importing .css into jsp document

How to link a css file into a jsp file. My jsp file is in /WEB-INF/Pages/connection.jsp My css file is in /WEB-INf/Pages/style.css .

Upvotes: 1

Views: 144

Answers (3)

Neil McGuigan
Neil McGuigan

Reputation: 48287

  1. Don't put public+static resources in WEB-INF (WEB-INF is for protected resources, like JSPs)

  2. Put public resources in webapp/static (pages is not a good names for things that aren't pages)

  3. Use JSTL core url tag for URLs:

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <link rel="stylesheet" href="<c:url value='/static/styles/style.css'/>">

  4. Use lowercase URLs (at least the domain and path)

Upvotes: 2

Y123
Y123

Reputation: 977

Your CSS and JS (any client side resources CANNOT reside in the WEB-INF folder as it is not visible outside - it can only be accessed from the server.

Upvotes: 1

Sathish
Sathish

Reputation: 337

In jsp file use that tag inside the header tag,

 <link rel="stylesheet" type="text/css" href="Pages/Style.css">

Upvotes: 2

Related Questions