logintest.jsp

来自「有完整的毕业设计所需的文件和代码 没什么说的了」· JSP 代码 · 共 51 行

JSP
51
字号
<%@ page contentType="text/html; charset=gb2312" language="java"%>
<%@page import="db.*,vo.*,java.util.*" %>
<%
String username=request.getParameter("USERID");
String password=request.getParameter("PASS");
String type=request.getParameter("type");
Sessions s=new Sessions();

if(type.equals("1")){
if(s.checkAdmin(username.trim(),password.trim())==null){
%>
<script language="javascript">
	alert("用户名或密码错误,或者没有这个用户的注册资料!");
	document.location.href="login.jsp";
</script>
<%	
}else{

	session.setAttribute("admin",s.checkAdmin(username.trim(),password.trim()));
	response.sendRedirect("index.jsp");
}
} 
%>
<%
if(type.equals("2")){
	if(s.checkUser(username.trim(),password.trim())==null){
%>
<script language="javascript">
	alert("用户名或密码错误,或者没有这个用户的注册资料!");
	document.location.href="login.jsp";
</script>
<%	
}else{

	session.setAttribute("user",s.checkUser(username.trim(),password.trim()));
	response.sendRedirect("index.jsp");
}
}
%>

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>登录测试</title>
</head>

<body>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?