文件名:Default.jsp
<%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312" import="java.sql.*,com.Connect"%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
request.setCharacterEncoding("gb2312");
String name = request.getParameter("username");
String pwd = request.getParameter("password");
String role = request.getParameter("roles");
Connection conn = Connect.getConn();
PreparedStatement pstmt = null;
ResultSet rs = null;
String current = null;
String realName = null;
%>
<%
String checkT = "select * from teacher_login " + "where username = ?";
String checkOP = "select * from op_login " + "where op_name = ?";
%>
<%
try{
String _pwd = null; //临时存放所给用户名所对应的密码
if(role.equals("教师")){
pstmt = conn.prepareStatement(checkT);
pstmt.setString(1, name.trim());
rs = pstmt.executeQuery();
while(rs.next()){
_pwd = rs.getString("password");
}
if(pwd.equals(_pwd)){ //此处转入相关页面
session = request.getSession(true);
current = (String)session.getAttribute("current"); //获取当前登入用户的用户名
if(current == null || current != name)
current = name;
session.setAttribute("current", current);
//获得登录人员的真实姓名
pstmt = conn.prepareStatement(checkT);
pstmt.setString(1, current);
rs = pstmt.executeQuery();
while(rs.next()){
realName = rs.getString("real_name");
}
%>
<jsp:forward page="main1.jsp">
<jsp:param name="current" value='<%=current%>' />
<jsp:param name="realName" value='<%=realName%>'/>
<jsp:param name="role" value='老师'/>
<jsp:param name="location" value='系统介绍'/>
</jsp:forward>
<%
}
else
response.sendRedirect("error_login.htm");
}
else{
pstmt = conn.prepareStatement(checkOP);
pstmt.setString(1, name.trim());
rs = pstmt.executeQuery();
while(rs.next()){
_pwd = rs.getString("password");
}
if(pwd.equals(_pwd)){ //此处转入相关页面
session = request.getSession(true);
current = (String)session.getAttribute("current"); //获取当前登入用户的用户名
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>