0

This is my file under WEB-INF/jsp folders:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>jQuery Hello World</title>
    <script type="text/javascript" src="/WEB-INF/static/jquery-1.4.2.js"></script>
    </head>
    <script type="text/javascript">
    $(document).ready(function(){

        $("#flag").html("Hello World !! I have come from J Query World");
    });


    </script>

    <body>

    <font color="RED"> Hello World !! I have come from plain world</font>
    <font color="BLUE"> <div id="flag"></div></font>
    </body>
    </html>

and my jquery file is under WEB-INF/static what should i do so that my code works properly , i think path of .js file is causing the prob.

2 Answers2

1

WEB-INF is where you keep private files for your application that should not be accessible to the client.

Move your JS to somewhere accessible.

Community
  • 1
  • 1
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
0

The question is where is your jsp file.

As you said your jsp's path is : WEB-INF/jsp

So your js path should be this: src="../static/jquery-1.4.2.js"

Try this and i believe it will work. If it will not then try src="../WEB-INF/static/jquery-1.4.2.js", otherwise add a comment with your new state.