基于javaweb+mysql的jsp+servlet学生在线选课系统(管理员、教师、学生)(java+jsp+servlet+mysql)

基于javaweb+mysql的jsp+servlet学生在线选课系统(管理员、教师、学生)(java+jsp+servlet+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明


内容:源码+数据库脚本+word报告文档

管理员:个人信息、学生、老师、学生、课程等管理

教师:个人信息、成绩、选课管理、教室查看

学生:个人信息、成绩查看、选课和查看

eclipse或MyEclipse或idea

管理员

学生

教师

技术框架

CSS JavaScript JSP Servlet JDBC MySQL

基于javaweb+mysql的JSP+Servlet学生在线选课系统(管理员、教师、学生)(java+jsp+servlet+mysql)

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setAttribute("error", "deleteSuccess");
		request.getRequestDispatcher("Index.jsp").forward(request, response);

//		String no=request.getParameter("aid");
//		AdminService adminService=new AdminService();
//		boolean result=adminService.deleteByAid(no);
//		if(!result) {	//删除失败
//			request.setAttribute("error", "deleteError");
//			request.getRequestDispatcher("adminIndex.jsp").forward(request, response);
//		}
//		else {	//删除成功
//			request.setAttribute("error", "deleteSuccess");
//			request.getRequestDispatcher("Index.jsp").forward(request, response);
//		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}

@WebServlet("/AdminUpdateServlet")
public class AdminUpdateServlet extends HttpServlet {
	}

}

@WebServlet("/AdminUpdateServlet")
public class AdminUpdateServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String no=request.getParameter("aid");
		String pass1=request.getParameter("pass1");
		String pass2=request.getParameter("pass2");
		if(pass1.equals(pass2)) {
			AdminService adminService=new AdminService();
			boolean result=adminService.updateByAid(no, pass1);
			if(!result) {	//修改失败
				request.setAttribute("error", "updateError");
			}
			else {	//修改成功
				request.setAttribute("error", "updateSuccess");
			}
		}
		else {//两密码不一致
			request.setAttribute("error", "unlike");
		}
		request.getRequestDispatcher("adminMod.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

		request.getRequestDispatcher("gradeIns.jsp").forward(request, response);	
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}

@WebServlet("/StuDeleteServlet")
public class StuDeleteServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setAttribute("error", "deleteSuccess");
		request.getRequestDispatcher("Index.jsp").forward(request, response);

//		String no=request.getParameter("sid");
//		StudentService studentService=new StudentService();
//		boolean result=studentService.deleteBySid(no);
//		if(!result) {	//删除失败
//			request.setAttribute("error", "deleteError");
//			request.getRequestDispatcher("studentIndex.jsp").forward(request, response);
//		}
//		else {	//删除成功
//			request.setAttribute("error", "deleteSuccess");
//			request.getRequestDispatcher("Index.jsp").forward(request, response);
//		}
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}

@WebServlet("/TeaDeleteServlet")
public class TeaDeleteServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setAttribute("error", "deleteSuccess");
@WebServlet("/TeaUpdateServlet")
public class TeaUpdateServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String no=request.getParameter("tid");
		String pass1=request.getParameter("pass1");
		String pass2=request.getParameter("pass2");
		if(pass1.equals(pass2)) {
			TeacherService teacherService=new TeacherService();
			boolean result=teacherService.updateByTid(no, pass1);
			if(!result) {	//修改失败
				request.setAttribute("error", "updateError");
			}
			else {	//修改成功
				request.setAttribute("error", "updateSuccess");
			}
		}
		else {//两密码不一致
			request.setAttribute("error", "unlike");
		}
		request.getRequestDispatcher("teacherMod.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}

@WebServlet("/TeaAddGradeServlet")
public class TeaAddGradeServlet extends HttpServlet {
		else {//两密码不一致
			request.setAttribute("error", "unlike");
		}
		request.getRequestDispatcher("teacherMod.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}

@WebServlet("/TeaAddGradeServlet")
public class TeaAddGradeServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String sid=request.getParameter("sid");
		String cid=request.getParameter("cid");
		float grade=Float.parseFloat(request.getParameter("ack"));
		Grade score=new Grade(cid,sid,grade);	//封装到实体类
		
		TeacherService teacherService=new TeacherService();
		boolean result=teacherService.addGrade(score);
		if(!result) {	//添加失败
			request.setAttribute("error", "addError");
		}
		else {	//添加成功
			request.setAttribute("error", "addSuccess");
		}
		request.getRequestDispatcher("gradeIns.jsp").forward(request, response);	
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}

@WebServlet("/StuCourseAddServlet")
public class StuCourseAddServlet extends HttpServlet {	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String sid=request.getParameter("sid");
		String cid=request.getParameter("cid");
		Score score=new Score(sid,cid,"0");	//封装到实体类
		
		StudentService studentService=new StudentService();
		boolean result=studentService.addChooseCourse(score);
		if(!result) {	//添加失败
			request.setAttribute("error", "addError");
		}
		else {	//添加成功
			request.setAttribute("error", "addSuccess");
		}
		request.getRequestDispatcher("StuCourseQueryServlet").forward(request, response);	
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}

		doGet(request, response);
	}

}

@WebServlet("/CourseAllStuQueryServlet")
public class CourseAllStuQueryServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String no=request.getParameter("cid");
		TeacherService teacherService=new TeacherService();
		List<Student> students=teacherService.studentQuery(no);
		
		request.setAttribute("cid", no);
		request.setAttribute("students", students);
		request.getRequestDispatcher("gradestu.jsp").forward(request, response);
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}


@WebServlet("/CourseAllStuQueryServlet")
public class CourseAllStuQueryServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String no=request.getParameter("cid");
		TeacherService teacherService=new TeacherService();
		List<Student> students=teacherService.studentQuery(no);
		
		request.setAttribute("cid", no);
		request.setAttribute("students", students);
		request.getRequestDispatcher("gradestu.jsp").forward(request, response);
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}

@WebServlet("/TeaLookcourseQueryServlet")
public class TeaLookcourseQueryServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String no=request.getParameter("tid");
		TeacherService teacherService=new TeacherService();
			response.sendRedirect("StudentQueryAllServlet");
		}
		else {
			out.println("注册失败,该学生已存在,请检查学号是否正确!");
		}*/
		if(!result) {	//注册失败
			request.setAttribute("error", "addError");
		}
		else {	//注册成功
			request.setAttribute("error", "addSuccess");
		}
		request.getRequestDispatcher("addteacher.jsp").forward(request, response);	//StudentQueryAllServlet直接转发给StudentInfoList.jsp,不需要进行处理
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}

/**
 * Servlet implementation class CourseAddServlet
 */
@WebServlet("/CourseAddServlet")

@WebServlet("/TeaLookcourseQueryServlet")
public class TeaLookcourseQueryServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String no=request.getParameter("tid");
		TeacherService teacherService=new TeacherService();
		List<LookCourse> courses=teacherService.lookcourseQuery(no);
		
		request.setAttribute("courses", courses);
		request.getRequestDispatcher("lookcourse.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}


/**
 * Servlet implementation class AllStuQueryServlet
 */
@WebServlet("/AllStuQueryServlet")
public class AllStuQueryServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AllStuQueryServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		AdminService adminService=new AdminService();
		List<Student> students=adminService.allstudentQuery();
		request.setAttribute("students", students);
		request.getRequestDispatcher("selstudent.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}


@WebServlet("/StuCourseAddServlet")
public class StuCourseAddServlet extends HttpServlet {	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String sid=request.getParameter("sid");
		String cid=request.getParameter("cid");
		Score score=new Score(sid,cid,"0");	//封装到实体类
		
		StudentService studentService=new StudentService();
		boolean result=studentService.addChooseCourse(score);
		if(!result) {	//添加失败
			request.setAttribute("error", "addError");
		}
		else {	//添加成功
			request.setAttribute("error", "addSuccess");
		}
		request.getRequestDispatcher("StuCourseQueryServlet").forward(request, response);	
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}

@WebServlet("/StuCourseDelServlet")
public class StuCourseDelServlet extends HttpServlet {


//功能:查询某学生的所有课程
public class StuCourseQueryServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String no=request.getParameter("sid");
		StudentService studentService=new StudentService();
		List<Course> courses=studentService.courseQuery(no);
		
		request.setAttribute("courses", courses);
		request.getRequestDispatcher("courseSelAndDel.jsp").forward(request, response);		
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}

@WebServlet("/AllTeaQueryServlet")
public class AllTeaQueryServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		AdminService adminService=new AdminService();
		List<Teacher> teachers=adminService.allteacherQuery();
		request.setAttribute("teachers", teachers);
		request.getRequestDispatcher("selteacher.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);

}

@WebServlet("/TeaAddGradeServlet")
public class TeaAddGradeServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String sid=request.getParameter("sid");
		String cid=request.getParameter("cid");
		float grade=Float.parseFloat(request.getParameter("ack"));
		Grade score=new Grade(cid,sid,grade);	//封装到实体类
		
		TeacherService teacherService=new TeacherService();
		boolean result=teacherService.addGrade(score);
		if(!result) {	//添加失败
			request.setAttribute("error", "addError");
		}
		else {	//添加成功
			request.setAttribute("error", "addSuccess");
		}
		request.getRequestDispatcher("gradeIns.jsp").forward(request, response);	
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}

@WebServlet("/StuDeleteServlet")
public class StuDeleteServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setAttribute("error", "deleteSuccess");
		request.getRequestDispatcher("Index.jsp").forward(request, response);
		if(pass1.equals(pass2)) {
			TeacherService teacherService=new TeacherService();
			boolean result=teacherService.updateByTid(no, pass1);
			if(!result) {	//修改失败
				request.setAttribute("error", "updateError");
			}
			else {	//修改成功
				request.setAttribute("error", "updateSuccess");
			}
		}
		else {//两密码不一致
			request.setAttribute("error", "unlike");
		}
		request.getRequestDispatcher("teacherMod.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}

@WebServlet("/TeaAddGradeServlet")
public class TeaAddGradeServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String sid=request.getParameter("sid");
		String cid=request.getParameter("cid");
		float grade=Float.parseFloat(request.getParameter("ack"));
		Grade score=new Grade(cid,sid,grade);	//封装到实体类
		
		TeacherService teacherService=new TeacherService();
		boolean result=teacherService.addGrade(score);
		if(!result) {	//添加失败
			request.setAttribute("error", "addError");
		}
		else {	//添加成功
			request.setAttribute("error", "addSuccess");
		}
		request.getRequestDispatcher("gradeIns.jsp").forward(request, response);	
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
 * Servlet implementation class AdminDeleteServlet
 */
@WebServlet("/AdminDeleteServlet")
public class AdminDeleteServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setAttribute("error", "deleteSuccess");
		request.getRequestDispatcher("Index.jsp").forward(request, response);

//		String no=request.getParameter("aid");
//		AdminService adminService=new AdminService();
//		boolean result=adminService.deleteByAid(no);
//		if(!result) {	//删除失败
//			request.setAttribute("error", "deleteError");
//			request.getRequestDispatcher("adminIndex.jsp").forward(request, response);
//		}
//		else {	//删除成功
//			request.setAttribute("error", "deleteSuccess");
//			request.getRequestDispatcher("Index.jsp").forward(request, response);
//		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}

			request.setAttribute("error", "addError");
		}
		else {	//添加成功
			request.setAttribute("error", "addSuccess");
		}
		request.getRequestDispatcher("StuCourseQueryServlet").forward(request, response);	
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}

@WebServlet("/StuCourseDelServlet")
public class StuCourseDelServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String sid=request.getParameter("sid");
		String cid=request.getParameter("cid");
		request.setAttribute("sid", sid);	//转发时使用
		StudentService studentService=new StudentService();
		boolean result=studentService.courseDelete(sid,cid);
		if(!result) {	//删除失败
			request.setAttribute("error", "deleteError");
		}
		else {	//删除成功
			request.setAttribute("error", "deleteSuccess");
		}
		request.getRequestDispatcher("StuCourseQueryServlet").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

/**
 * Servlet implementation class TeacherAddServlet
 */
@WebServlet("/TeacherAddServlet")
public class TeacherAddServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public TeacherAddServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String tId=request.getParameter("tId");
		String tName=request.getParameter("tName");
		String tPass=request.getParameter("tPass");
		String dId=request.getParameter("dId");
		
		String tSex=request.getParameter("tSex");
		String tAge=request.getParameter("tAge");
		String tEdu=request.getParameter("tEdu");
		String tTitle=request.getParameter("tTitle");
		String tSch=request.getParameter("tSch");
		String tHealth=request.getParameter("tHealth");
		Teacher teacher=new Teacher(tId,tName,tPass,dId,tSex,tAge,tEdu,tTitle,tSch,tHealth);	//封装到实体类
		AdminService adminService=new AdminService();
		boolean result=adminService.addTeacher(teacher);
		//PrintWriter out=response.getWriter();
		/*if(result) {			
			out.println("注册成功!");
			response.sendRedirect("StudentQueryAllServlet");
		}
		else {
			out.println("注册失败,该学生已存在,请检查学号是否正确!");
		}*/

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

建设网站主要包括:教学管理人员和学员对系统的登陆功能;教学管理人员对学员、课程、考试成绩等信息的检索和维护功能;学员对个人信息检索和维护,对在线选课和成绩等信息的检索功能。 4. 系统需求分析与概要设计 本系统应该完成以下工作: 1.用户等级分为未登录用户和登录用户,而登录用户包括学员,班主任和网站管理员。 2.网院概况,即网络教育学院的介绍。目的是让网上用户可以了解本网络教育学院信息, 规章制度和学院拥有的教学站。 3.新闻中心,目的是让网上用户可以了解学院新闻和教务通知。 4.招生专栏,目的是让网上用户了解最新的招生简章、招生计划、专业设置以及用户遇到的常见问题和咨询联系方式。 5.学习专栏,目的是让网上用户可以了解关于学习方面的动态,比如教务通知、教学计划、考试安排。并通过网上学习掌握知识,比如毕业设计辅导等。 7.网上导航,目的是让网上用户方便的浏览该网站。 8.学生功能,以学生身份登陆后访问,进行在线学习相关功能。包含在线选课、 注册考试、注册考试查询、成绩查询、学分查询、个人信息查询和修改、申请毕业 等功能。 9.班主任功能,以班主任身份登陆后访问,进行对班上学生管理的相关功能。包含班级学生选课查询,班级学生注册考试查询,班级学生考试成绩查询,班级学 生信息查询等功能。 10.管理员功能,以管理员身份登陆后访问,进行网站管理员功能。包含网站信息修改,新闻和通知的维护等功能。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值