AHmedRef
AHmedRef

Reputation: 2611

How to Include a JS/CSS File in JSP (TOMCAT PROJECT)

i have an external javascript and css file and i want to incude it into my JSP file so im trying to test this code but is not working :

i don't want to use "include file='file.css'"

<html>
   <head>
      <link href="css/bootstrap.min.css" rel="stylesheet"/>
      <script src="js/jquery-latest.js"></script>
      <script src="js/bootstrap.min.js"></script>
   </head>
   <body>
      <form class="form-horizontal well">
        login  : <input type="text">
        <br/>
        passw  : <input type="password">
        </form>
   </body>
</html>

Upvotes: 1

Views: 22531

Answers (1)

rootkit
rootkit

Reputation: 2165

Use

<link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet"/>

See http://docs.oracle.com/javaee/5/api/javax/servlet/http/HttpServletRequest.html#getContextPath%28%29

Upvotes: 6

Related Questions