JSP JBuilder在线教学系统-源代码|计算机专业全套免费毕业设计论文网
本系统绝对免费,若要全部代码全联系站长QQ752018766
JSP登录系统界面JSP源代码login.jsp
<%@ page contentType="text/html; charset=GBK" %><!--指定本页文字编码为GBK-->
<%@page import="grad.util.user.*;"%><!--引入user包下的user和op_user类-->
<%@ page session="true" %><!--设置session有效-->
<html>
<head>
<title>
login
</title>
</head>
<body bgcolor="#ffffff">
<h1>
<%
String password=request.getParameter("password");
String usercode=request.getParameter("user");
String type=request.getParameter("type");
op_user ope=new op_user();//构造用户管理对象
if(ope.isLogin(usercode,password,type)){//调用isLogin方法判断是否允许用户登录
user us=ope.getUserByUserCode(usercode,type);//允许用户登录则取得用户信息
session.setAttribute("usercode",usercode);//把用户编号写入session
session.setAttribute("usertype",new Integer(us.getType()));//把用户类型写入session
switch (us.getType())
{
case 1:response.sendRedirect("student/index.htm");break; //登录用户是学生
case 2:response.sendRedirect("teacher/index.htm");break; //登录用户是老师
case 3:response.sendRedirect("admin/index.htm");break; //登录用户是管理员
default:response.sendRedirect("index.jsp");break;
}
}else{
out.print("<script language=\"javascript\">alert(\"请重新登录\")</script>");
response.sendRedirect("index.jsp");
}
%>
</h1>
</body>
</html>
网站首页index.jsp源代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网上教学</title>
</head>
<body>
<table width="75%" height="350" border="0" align="center">
<tr>
<td height="124" colspan="3"><img src="img/head.jpg" width="799" height="120"></td>
</tr>
<tr>
<td height="163"> </td>
<td align="center" valign="middle">
<form name="login" action="login.jsp">
<table width="43%" border="0">
<tr>
<td align="right">用户名:</td>
<td><input name="user" type="text" size="15"></td>
</tr>
<tr>
<td align="right">密 码:</td>
<td><input name="password" type="password" size="15"></td>
</tr>
<tr>
<td colspan="2"> <input type=radio name="type" value=1 checked><font size="2">学生</font><input type=radio name="type" value=2><font size="2">教师</font><input type=radio name="type" value=3><font size="2">管理员</font></td>
</tr>
<tr>
<td align="right">
<input name="submit" type="submit" value="登录">
</td>
<td><input name="reset" type="reset" value="重置"></td>
</tr>
</table>
</form>
</td>
<td> </td>
</tr>
<tr align="center" valign="middle">
<td height="55" colspan="3"><%@ include file="inc/tail.htm"%></td>
</tr>
</table>
</body>
</html>