How to call JS function within .js file into .jsp file?

Posted by Simple-Solution on Stack Overflow See other posts from Stack Overflow or by Simple-Solution
Published on 2012-07-07T15:07:55Z Indexed on 2012/07/07 15:15 UTC
Read the original article Hit count: 150

Filed under:
|

I am trying to call a javaScript function that's in .../js/index.js file to .../index.jsp file.

Any suggestion would be helpful.

Here is code within both file:

index.js

function testing() {

    if ("c" + "a" + "t" === "cat") {
        document.writeln("Same");
    } else {
        document.writeln("Not same");
    };
};

index.jsp

<%@ 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>Insert title here</title>
</head>
<body>

    <script type="text/javascript" src="js/index.js">

       <!-- I want to call testing(); function here -->

    </script>
</body>
</html>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jsp