login.html
复制代码 代码如下:
<script> <P>function request(id,url){<BR> oScript = document.getElementById(id);<BR> var head = document.getElementsByTagName("head").item(0);<BR> if (oScript) {<BR> head.removeChild(oScript);<BR> }<BR> oScript = document.createElement("script");<BR> oScript.setAttribute("src", url);<BR> oScript.setAttribute("id",id);<BR> oScript.setAttribute("type","text/javascript");<BR> oScript.setAttribute("language","javascript");<BR> head.appendChild(oScript);<BR> return oScript;<BR>} <P> <P>function userLogin(){<BR> var username=document.getElementById('name').value;<BR> var password=document.getElementById('password').value;<br><br> //alert(username+"--"+password);<br><br> var url='http://127.0.0.1:8080/EasyCMS/login.jsp?name='+encodeURI(username)+'&password='+encodeURI(password)+'&s=' + (new Date()).getTime(); <P> //alert("url="+url);<BR> var login=request("loginScript",url);<BR>} <P>function myloginState(state){ <P> alert("ret:"+state);<BR> if (state==0)<BR> {<BR> alert("登陆成功");<BR> }<BR> else<BR> {<BR> alert("登陆失败");<BR> } <P>} <P></script>
用户名:
密码:
login.jsp
复制代码 代码如下:
String name=request.getParameter("name");
String password=request.getParameter("password");
if (name.equals("admin") && password.equals("admin"))
{
request.getSession().setAttribute("admin","admin");
%>
myloginState("0");
}
else
{
%>
myloginState("1");
}
%>