login.html
复制代码代码如下:
<script>
طلب الوظيفة (id ، url) {
oscript = document.getElementById (id) ؛
var head = document.getElementSbyTagName ("head"). البند (0) ؛
if (oscript) {
head.removechild (Oscript) ؛
}
oscript = document.createElement ("script") ؛
oscript.setattribute ("SRC" ، url) ؛
oscript.setattribute ("id" ، id) ؛
oscript.setattribute ("type" ، "text/javaScript") ؛
oscript.setattribute ("اللغة" ، "JavaScript") ؛
Head.AppendChild (Oscript) ؛
إرجاع Oscript ؛
}
وظيفة userlogin () {
var username = document.getElementById ('name'). value ؛
var password = document.getElementById ('كلمة المرور'). القيمة ؛
// ALERT (اسم المستخدم+"-"+كلمة المرور) ؛
var url = 'http: //127.0.0.1: 8080/easycms/login.jsp؟ name ='+encodeuri (username)+'& password ='+encodeuri (password)+'& s ='+(date ()) .getTime () ؛
// ALERT ("url ="+url) ؛
var login = request ("loginscript" ، url) ؛
}
وظيفة myloginstate (الحالة) {
تنبيه ("ret:"+state) ؛
إذا (الحالة == 0)
{
تنبيه ("登陆成功") ؛
}
آخر
{
تنبيه ("登陆失败") ؛
}
}
</script>
<body>
: : <input name = "name" id = "name" type = "text" />
: : <input name = "password" id = "password" type = "password" />
<name input = "" value = "login" type = "button" onClick = "UserLogin () ؛" />
</body>
login.jsp
复制代码代码如下:
<٪@ page language = "java" import = "java.util.*" pageencoding = "utf-8" ٪>
<٪
اسم السلسلة = request.getParameter ("name") ؛
سلسلة كلمة مرور = request.getParameter ("كلمة المرور") ؛
if (name.equals ("admin") && password.equals ("admin"))
{
request.getSession (). setAttribute ("admin" ، "admin") ؛
٪>
myloginstate ("0") ؛
<٪
}
آخر
{
٪>
myloginstate ("1") ؛
<٪
}
٪>