1

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>
2
  • 1
    When you say "doesn't work" what exactly you mean? You say these files are external. If so, you have to provide an absolute URI for the src like http://domain.com/css/default.css Commented Feb 20, 2013 at 12:35
  • yes it's correct what you said but if i have change my directorie projet i'll also change my code so is not good :D Commented Feb 20, 2013 at 12:42

1 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

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.