<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<%!
public String codeToString(String str)
{//处理中文字符串的函数
String s=str;
try
{
byte tempB[]=s.getBytes("ISO-8859-1");
s=new String(tempB);
return s;
}
catch(Exception e)
{
return s;
}
}
%>
<html>
<body>
<%//接收客户端提交的数据
String username=codeToString(request.getParameter("user"));
if(username==null)//无内容则设为空串
username="";
String pw=codeToString(request.getParameter("password"));
if(pw==null)//无内容则设为空串
pw="";
String str_result="";
if(username.equals("lxh") && pw.equals("haoren")){
//out.print("loader登录成功!");
//out.print("<br />");
Cookie loader_cookie =new Cookie("lxh","haoren");
str_result="loader";
}else if(username.equals("guest") && pw.equals("")){
str_result="guest";
}else{
str_result="error";
}
%>
<script type="text/javascript">
function back_login() // 返回
{
alert("密码错误,请重新登录!");
window.location.href="index.html";
}
var s_result="<%=str_result%>";
//alert(s_result);
if(s_result=="loader"){
alert("loader登录成功!\n 开发中....");
window.location.href="index.html";
}else if(s_result=="guest"){
alert("guest登录成功!\n 开发中....");
window.location.href="index.html";
}else{
back_login();
}
</script>
</body>
</html>
<%!
public String codeToString(String str)
{//处理中文字符串的函数
String s=str;
try
{
byte tempB[]=s.getBytes("ISO-8859-1");
s=new String(tempB);
return s;
}
catch(Exception e)
{
return s;
}
}
%>
<html>
<body>
<%//接收客户端提交的数据
String username=codeToString(request.getParameter("user"));
if(username==null)//无内容则设为空串
username="";
String pw=codeToString(request.getParameter("password"));
if(pw==null)//无内容则设为空串
pw="";
String str_result="";
if(username.equals("lxh") && pw.equals("haoren")){
//out.print("loader登录成功!");
//out.print("<br />");
Cookie loader_cookie =new Cookie("lxh","haoren");
str_result="loader";
}else if(username.equals("guest") && pw.equals("")){
str_result="guest";
}else{
str_result="error";
}
%>
<script type="text/javascript">
function back_login() // 返回
{
alert("密码错误,请重新登录!");
window.location.href="index.html";
}
var s_result="<%=str_result%>";
//alert(s_result);
if(s_result=="loader"){
alert("loader登录成功!\n 开发中....");
window.location.href="index.html";
}else if(s_result=="guest"){
alert("guest登录成功!\n 开发中....");
window.location.href="index.html";
}else{
back_login();
}
</script>
</body>
</html>