Boa tarde pessoal, to eu aqui de novo.
Tô chamando um método dentro do onclick de um button aqui na jsp, e esse msm metodo ta no arquivo "WEB-INF/resources/js/teste.js", e a minha jsp ta em "WEB-INF/views/teste-sha256.jsp".
Seguem os códigos abaixo:
JSP teste-sha256.jsp
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="<c:url value='/resources/js/teste.js' />">
</script>
<title>Insert title here</title>
</head>
<body>
<form name="form" id="form" method="post">
<table cellpadding="0" cellspacing="0" align="center">
<tr>
<td> <input type="text" id="senha" name="senha" /> </td>
</tr>
<tr>
<td> <input type="button" value="Button" onclick="teste.alertar()" /> </td>
</tr>
</table>
</form>
</body>
</html>
function alertar() {
alert("TESTANDO AQUI");
}
Acontece que no evento onclick do button, eu já tentei chamar dessas formas:
onclick="teste.alertar()"
onclick="teste.alertar();"
onclick="alertar()"
onclick="alertar();"
E de forma alguma esse código javascript é executado. Quando coloco o código javascript dentro da jsp, funciona. O mais estranho é que tenho ouros códigos javascript aqui, em que chamo o arquivo usando JSTL, e funciona numa boa.
Talvez eu tenha me esquecido de algo, quem puder ajudar com qlq idéia, agradeço mto.
Abraços.
