function test(){
alert("这里可以写!")
}
</script>
直接在页面写就行了,把jsp当html就行了。。没区别的。
你说的那个也可以,在servlet中输出
如response.getWriter().print("<script>alert('你好!')</script>")
jsp代码中间插入JS代码的格式,代码如下:
<script lanuage="javascript">function justiice(t){if (t>0){
alert("account is exsiting")
}
}
else{
'redirect the other page!'
}
</script>
<%int i=conn.executeQuery("select count(1) fromtable where id='输入帐户'")%>
<input type=button onclick=justiice('<%=i%>')>
<! But i want to tell you that the sql statement you can't insert into your current page, it may incur SQL injection,Be cautious!>
在JSP中<head></head>标签中引入<script type="text/javascript" src="js/**.js" ></script>js文件,或者直接在<script></script>中直接写js代码。