I have a bit of a problem here.

The situation.

1. I have created a Dynamic Web Project. (good)
2. I have created a logon JSP (good)
3. I have created a css (good)
4. I have created a JS file (good)

JSP, CSS are located in WebContent/WEB-INF/
JS located in WebContent.

The issue.


My JS functions are not working.


this is a part of my jsp

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/JavaScript" language="JavaScript" src="alerts.js"></script>
<link rel="stylesheet" type="text/css" href="ibs.css" />
<title>hehehehehe</title>
</head>
<body >
<form>
<button class="with_border" type="submit" value="submit" onClick="greet()">Submit</button>
</form>
</body>
</html>

this is my JS File

function greet()
{
	alert('Hello');
}

When I click the submit button nothing happens, the Hello is not displayed.

However, when i tried this

<button class="with_border" type="submit" value="submit" onClick="alert('Hello')">Submit</button>

it works. ??

Application cannot find pages (JSP) as their are in wrong location. In basic setup as you showed here they should be on same level as WEB-INF that means in WebContent. There is a way to have them in different location but then you would have to set it in web.xml if I'm not mistaken

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.