⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dologin.jsp

📁 这是一个很好的系统 希望大家喜欢 漫漫看
💻 JSP
字号:
<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<jsp:directive.page import="ss06.sl.pj3.*" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<title>Dologin</title>
</head>
<body>
	<%	request.setCharacterEncoding("GB2312");
		DBUtil dbutil = DBUtil.getInstance();
		dbutil.connect2DB();
		String username;
		try {
			if(session.getAttribute("username") == null){
				session.setAttribute("username", request.getParameterValues("userName")[0]);
				session.setAttribute("password", request.getParameterValues("password")[0]);
				username = session.getAttribute("username").toString();
				String password = session.getAttribute("password").toString();
				username = dbutil.checkUser(username, password);
			}else{
				username = session.getAttribute("username").toString();
			}
		} catch (Exception e) {
			username = null;
		}
		if (username != null) {
			session.setAttribute("username", username);
			session.setAttribute("role", dbutil.getRole(username));
			session.setAttribute("shoppingcart", null);
			if(dbutil.getRole(username).equals("admin")){
				response.sendRedirect("adminIndex.jsp");
			}else{
				response.sendRedirect("userIndex.jsp");
			}
		}else{
			out.println("用户名或密码有误!<br>");
			out.println("<a href=\"javascript:history.back();\">返回登录页面</a>");
			session.invalidate();
		}
	%>
</body>
</html>

⌨️ 快捷键说明

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