基于javaweb+mysql的jsp+servlet在线学生选课管理系统(java+jsp+bootstrap+jquery+servlet+mysql)

基于javaweb+mysql的jsp+servlet在线学生选课管理系统(java+jsp+bootstrap+jquery+servlet+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

基于javaweb+mysql的JSP+Servlet在线学生选课管理系统(java+jsp+bootstrap+jquery+servlet+mysql)

项目介绍

管理员角色包含以下功能: 管理员登录,学生管理,教师管理,班级管理,添加班级,添加教师,添加学生,课程管理,添加课程,系统用户管理,添加用户,修改密码等功能。

教师角色包含以下功能: 教师登录,选课管理,添加选课学生,成绩管理,添加成绩,查看学生信息,查看班级信息,查看个人档案,修改密码等功能。

学生角色包含以下功能: 学生登录,选课管理,成绩查看,查看个人档案,修改密码等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目

技术栈

  1. 后端:servlet 2. 前端:JSP+bootstrap+jQuery

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中db.properties与spring-mybatis.xml配置文件中的数据库配置改为自己的配置; 注:在spring-mybatis.xml没有将db.properties的数据同步过去的情况下修改; 4. 运行项目,输入localhost:8080/chaoshi 登录 注:tomcat中配置项目路径必须为/chaoshi,前端代码中已写死,否则会报错;
}
package servlet;

public class TaokeServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public TaokeServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		}
		
		if(taoke != null && !taoke.equals("")){
			str = "/jiaoshi/taoke_list.jsp";
			sql = "delete from taoke where id="+taoke;
			ib.insertANDupdateANDdel(sql);
			request.setAttribute("message", "操作成功!");
		}
		
		if(tuike != null && !tuike.equals("")){
			str = "/xuesheng/kecheng_list.jsp";
			sql = "delete from xuanke where id="+tuike;
			ib.insertANDupdateANDdel(sql);
			request.setAttribute("message", "操作成功!");
		}
		
		RequestDispatcher rd = request.getRequestDispatcher(str);
        rd.forward(request,response);
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
package servlet;

public class XueshengServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public XueshengServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
    {
        m_maxFileSize = l;
    }

    protected String getPhysicalPath(String s,int i) throws IOException
    {
        String s1 = ""; //new String();
        String s2 = ""; //new String();
        String s3 = ""; //new String();
        boolean flag = false;
        s3 = System.getProperty("file.separator");
        if(s == null)
        {
            throw new IllegalArgumentException("There is no specified destination file (1140).");
        }
        if(s.equals(""))
        {
            throw new IllegalArgumentException("There is no specified destination file (1140).");
        }
        if(s.lastIndexOf("\\") >= 0)
        {
            s1 = s.substring(0,s.lastIndexOf("\\"));
            s2 = s.substring(s.lastIndexOf("\\") + 1);
        }
        if(s.lastIndexOf("/") >= 0)
        {
            s1 = s.substring(0,s.lastIndexOf("/"));
            s2 = s.substring(s.lastIndexOf("/") + 1);
        }
        s1 = s1.length() != 0 ? s1 : "/";
        java.io.File file = new java.io.File(s1);
        if(file.exists())
        {
            flag = true;
        }
        if(i == 0)
        {
            if(isVirtual(s1))
            {
                s1 = m_application.getRealPath(s1);
                if(s1.endsWith(s3))
                {
                    s1 = s1 + s2;
                }
                else
                {
                    s1 = s1 + s3 + s2;
                }
                return s1;
            java.io.File file = new java.io.File(s);
            FileOutputStream fileoutputstream = new FileOutputStream(file);
            fileoutputstream.write(m_binArray);
            fileoutputstream.close();
        }
        catch(Exception exception1)
        {
            throw new SmartUploadException("The Form cannot be saved in the specified file (1030).");
        }
    }

    private boolean isVirtual(String s)
    {
        if(m_application.getRealPath(s) != null)
        {
            java.io.File file = new java.io.File(m_application.getRealPath(s));
            return file.exists();
        }
        else
        {
            return false;
        }
    }
}
package servlet;

public class DelServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		response.setContentType("text/html;charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		
		String mark = request.getParameter("mark");
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		String pwd = request.getParameter("pwd");
		String banji = request.getParameter("banji");
		String xuehao = request.getParameter("xuehao");
		String zhiwu = request.getParameter("zhiwu");
		String zhenname = request.getParameter("zhenname");
        int i = 0;
        i = s.indexOf("/") + 1;
        if(i != -1)
        {
            int j = s.length();
            return s.substring(i,j);
        }
        else
        {
            return s;
        }
    }

    private String getContentDisp(String s)
    {
        //String s1 = new String();
        String s1 = "";
        int i = 0;
        int j = 0;
        i = s.indexOf(":") + 1;
        j = s.indexOf(";");
        s1 = s.substring(i,j);
        return s1;
    }

    private void getDataSection()
    {
        //boolean flag = false;
        //String s = "";
        //String s = new String();
        int i = m_currentIndex;
        int j = 0;
        int k = m_boundary.length();
        m_startData = m_currentIndex;
        m_endData = 0;
        while(i < m_totalBytes)
        {
            if(m_binArray[i] == (byte)m_boundary.charAt(j))
            {
                if(j == k - 1)
                {
                    m_endData = ((i - k) + 1) - 3;
                    break;
                }
                i++;
                j++;
            }
            else
            {
            {
                m_response.setContentType("application/x-msdownload");
            }
            else
            {
                m_response.setContentType(s1);
            }
        }
        m_response.setContentLength(abyte0.length);
        if(s2 == null)
        {
            m_response.setHeader("Content-Disposition","attachment;");
        }
        else
        {
            if(s2.length() == 0)
            {
                m_response.setHeader("Content-Disposition","attachment;");
            }
            else
            {
                m_response.setHeader("Content-Disposition","attachment; filename=" + s2);
            }
        }
        m_response.getOutputStream().write(abyte0,0,abyte0.length);
    }

    public void fieldToFile(ResultSet resultset,String s,String s1) throws ServletException,IOException,SmartUploadException,SQLException
    {
        try
        {
            if(m_application.getRealPath(s1) != null)
            {
                s1 = m_application.getRealPath(s1);
            }
            InputStream inputstream = resultset.getBinaryStream(s);
            FileOutputStream fileoutputstream = new FileOutputStream(s1);
            int i;
            while((i = inputstream.read()) != -1)
            {
                fileoutputstream.write(i);
            }
            fileoutputstream.close();
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		
		response.setContentType("text/html;charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		
		String mark = request.getParameter("mark");
		String id = request.getParameter("id");
		String name = request.getParameter("name");

public class RemoveServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public RemoveServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String mark = request.getParameter("mark");
		String str ="";
		HttpSession session = request.getSession();
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		
		String mark = request.getParameter("mark");
		String id = request.getParameter("id");
		String xuesheng = request.getParameter("xuesheng");
		String kemu = request.getParameter("kemu");
		String shijian = request.getParameter("shijian");
		String fenshu = request.getParameter("fenshu");
		
		String str = "";
		String sql = "";
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		
		if(mark != null && mark.equals("add")){
			str = "/jiaoshi/chengji_list.jsp";
			sql = "insert into chengji(xuesheng,kemu,shijian,fenshu) values('"+xuesheng+"','"+kemu+"','"+shijian+"','"+fenshu+"')";
			ib.insertANDupdateANDdel(sql);
			request.setAttribute("message", "操作成功!");
		}
		if(mark != null && mark.equals("update")){
			str = "/jiaoshi/chengji_list.jsp";
			sql = "update chengji set xuesheng='"+xuesheng+"',kemu='"+kemu+"',shijian='"+shijian+"',fenshu='"+fenshu+"' where id="+id;
		String xuehao = request.getParameter("xuehao");
		String zhiwu = request.getParameter("zhiwu");
		String zhenname = request.getParameter("zhenname");
		String sex = request.getParameter("sex");
		String shengri = request.getParameter("shengri");
		String zuohao = request.getParameter("zuohao");
		String shenfenzheng = request.getParameter("shenfenzheng");
		String minzu = request.getParameter("minzu");
		String jiguan = request.getParameter("jiguan");
		String hukou = request.getParameter("hukou");
		String address = request.getParameter("address");
		String phone = request.getParameter("phone");
		String email = request.getParameter("email");
		String beizhu = request.getParameter("beizhu");
		
		String str = "";
		String sql = "";
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		
		if(mark != null && mark.equals("add")){
			str = "/admin/xuesheng_list.jsp";
			sql = "insert into xuesheng(name,pwd,banji,xuehao,zhiwu,zhenname,sex,shengri,zuohao,shenfenzheng,minzu,jiguan,hukou,address,phone,email,beizhu,shenfen) values('"+name+"','"+pwd+"','"+banji+"','"+xuehao+"','"+zhiwu+"','"+zhenname+"','"+sex+"','"+shengri+"','"+zuohao+"','"+shenfenzheng+"','"+minzu+"','"+jiguan+"','"+hukou+"','"+address+"','"+phone+"','"+email+"','"+beizhu+"','xuesheng')";
			int flag = ib.insertANDupdateANDdel(sql);
			if(flag == -1){
				str = "/admin/xuesheng.jsp?mark="+mark;
				request.setAttribute("message", "用户名或学号重复!");
			}else{
				request.setAttribute("message", "操作成功!");
			}
		}
		if(mark != null && mark.equals("update")){
			str = "/admin/xuesheng_list.jsp";
			sql = "update xuesheng set banji='"+banji+"',xuehao='"+xuehao+"',zhiwu='"+zhiwu+"',zhenname='"+zhenname+"',sex='"+sex+"',shengri='"+shengri+"',zuohao='"+zuohao+"',shenfenzheng='"+shenfenzheng+"',minzu='"+minzu+"',jiguan='"+jiguan+"',hukou='"+hukou+"',address='"+address+"',phone='"+phone+"',email='"+email+"',beizhu='"+beizhu+"' where id="+id;
			int flag = ib.insertANDupdateANDdel(sql);
			if(flag == -1){
				str = "/admin/xuesheng.jsp?mark="+mark+"&id="+id;
				request.setAttribute("message", "学号重复!");
			}else{
				request.setAttribute("message", "操作成功!");
			}
		}
		
		RequestDispatcher rd=request.getRequestDispatcher(str);
        rd.forward(request,response);
	}

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

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		response.setContentType("text/html;charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		
		String mark = request.getParameter("mark");
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		String pwd = request.getParameter("pwd");
		String banji = request.getParameter("banji");
		String xuehao = request.getParameter("xuehao");
		String zhiwu = request.getParameter("zhiwu");
		String zhenname = request.getParameter("zhenname");
		String sex = request.getParameter("sex");
		String shengri = request.getParameter("shengri");
		String zuohao = request.getParameter("zuohao");
		String shenfenzheng = request.getParameter("shenfenzheng");
		String minzu = request.getParameter("minzu");
		String jiguan = request.getParameter("jiguan");
		String hukou = request.getParameter("hukou");
		String address = request.getParameter("address");
		String phone = request.getParameter("phone");
		String email = request.getParameter("email");
		String beizhu = request.getParameter("beizhu");
		
		String str = "";
		String sql = "";
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
package servlet;

public class ChengjiServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public ChengjiServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		
		String sql = "";
		String str = "";
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		AllBean ab = new AllBean();
		
		String adminid = request.getParameter("adminid");
		String laoshi = request.getParameter("laoshi");
		String xuesheng = request.getParameter("xuesheng");
		String banji = request.getParameter("banji");
		String kecheng = request.getParameter("kecheng");
		String chengji = request.getParameter("chengji");
}
package servlet;

public class KechengtableServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public KechengtableServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
}
package servlet;

public class DelServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public DelServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		response.setContentType("text/html;charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		
		String id = request.getParameter("id");
		HttpSession  session = request.getSession();
		ArrayList adminlogin = (ArrayList)session.getAttribute("adminlogin");
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		String sql = "insert into xuanke(xuesheng,kecheng) values("+adminlogin.get(0)+","+id+")";
		ib.insertANDupdateANDdel(sql);
		request.setAttribute("message", "操作成功!");
		
		request.getRequestDispatcher("/xuesheng/kecheng_list.jsp").forward(request, response);
	}

            FileOutputStream fileoutputstream = new FileOutputStream(file);
            fileoutputstream.write(m_binArray);
            fileoutputstream.close();
        }
        catch(Exception exception1)
        {
            throw new SmartUploadException("The Form cannot be saved in the specified file (1030).");
        }
    }

    private boolean isVirtual(String s)
    {
        if(m_application.getRealPath(s) != null)
        {
            java.io.File file = new java.io.File(m_application.getRealPath(s));
            return file.exists();
        }
        else
        {
            return false;
        }
    }
}
package servlet;

public class DelServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public DelServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
                    s1 = s1 + s3 + s2;
                }
                return s1;
            }
            if(flag)
            {
                if(m_denyPhysicalPath)
                {
                    throw new IllegalArgumentException("Physical path is denied (1125).");
                }
                else
                {
                    return s;
                }
            }
            else
            {
                throw new IllegalArgumentException("This path does not exist (1135).");
            }
        }
        if(i == 1)
        {
            if(isVirtual(s1))
            {
                s1 = m_application.getRealPath(s1);
                if(s1.endsWith(s3))
                {
                    s1 = s1 + s2;
                }
                else
                {
                    s1 = s1 + s3 + s2;
                }
                return s1;
            }
            if(flag)
            {
                throw new IllegalArgumentException("The path is not a virtual path.");
            }
            else
            {
                throw new IllegalArgumentException("This path does not exist (1135).");
            }
        }
        if(i == 2)
        {
            if(flag)
		String sql = "";
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		
		if(mark != null && mark.equals("add")){
			str = "/admin/jiaoshi_list.jsp";
			sql = "insert into jiaoshi(name,pwd,jiaoshihao,zhenname,sex,shengri,yuanxiao,zhuanye,phone,address,email,shenfen) values('"+name+"','"+pwd+"','"+jiaoshihao+"','"+zhenname+"','"+sex+"','"+shengri+"','"+yuanxiao+"','"+zhuanye+"','"+phone+"','"+address+"','"+email+"','laoshi')";
			int flag = ib.insertANDupdateANDdel(sql);
			if(flag == -1){
				str = "/admin/jiaoshi.jsp?mark="+mark;
				request.setAttribute("message", "用户名或教师号重复!");
			}else{
				request.setAttribute("message", "操作成功!");
			}
		}
		if(mark != null && mark.equals("update")){
			str = "/admin/jiaoshi_list.jsp";
			sql = "update jiaoshi set jiaoshihao='"+jiaoshihao+"',zhenname='"+zhenname+"',sex='"+sex+"',shengri='"+shengri+"',yuanxiao='"+yuanxiao+"',zhuanye='"+zhuanye+"',phone='"+phone+"',address='"+address+"',email='"+email+"' where id="+id;
			int flag = ib.insertANDupdateANDdel(sql);
			if(flag == -1){
				str = "/admin/jiaoshi.jsp?mark="+mark+"&id="+id;
				request.setAttribute("message", "教师号重复!");
			}else{
				request.setAttribute("message", "操作成功!");
			}
		}
		
		RequestDispatcher rd=request.getRequestDispatcher(str);
        rd.forward(request,response);
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
package servlet;

			}
		}
		if(mark != null && mark.equals("update")){
			str = "/admin/jiaoshi_list.jsp";
			sql = "update jiaoshi set jiaoshihao='"+jiaoshihao+"',zhenname='"+zhenname+"',sex='"+sex+"',shengri='"+shengri+"',yuanxiao='"+yuanxiao+"',zhuanye='"+zhuanye+"',phone='"+phone+"',address='"+address+"',email='"+email+"' where id="+id;
			int flag = ib.insertANDupdateANDdel(sql);
			if(flag == -1){
				str = "/admin/jiaoshi.jsp?mark="+mark+"&id="+id;
				request.setAttribute("message", "教师号重复!");
			}else{
				request.setAttribute("message", "操作成功!");
			}
		}
		
		RequestDispatcher rd=request.getRequestDispatcher(str);
        rd.forward(request,response);
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
package servlet;

public class BanjiServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public BanjiServlet() {
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		
		String sql = "";
		String str = "";
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		AllBean ab = new AllBean();
		
		String adminid = request.getParameter("adminid");
		String laoshi = request.getParameter("laoshi");
		String xuesheng = request.getParameter("xuesheng");
		String banji = request.getParameter("banji");
		String kecheng = request.getParameter("kecheng");
		String chengji = request.getParameter("chengji");
		String kechengtable = request.getParameter("kechengtable");
		String kechengid = request.getParameter("kechengid");
		String taoke = request.getParameter("taoke");
		String tuike = request.getParameter("tuike");
		
		if(adminid != null && !adminid.equals("")){
			str = "/admin/adminlist.jsp";
			sql = "delete from admin where id="+adminid;
			if(adminid.equals("1")){
				request.setAttribute("message", "系统管理员不能删除!");
			}else{
				ib.insertANDupdateANDdel(sql);
				request.setAttribute("message", "操作成功!");
			}
		}
		
		if(laoshi != null && !laoshi.equals("")){
			str = "/admin/jiaoshi_list.jsp";
			sql = "delete from jiaoshi where id="+laoshi;
			ib.insertANDupdateANDdel(sql);
			sql = "update banji set banzhuren=0 where banzhuren="+laoshi;
			ib.insertANDupdateANDdel(sql);
            {
                m_response.setContentType("application/x-msdownload");
            }
            else
            {
                m_response.setContentType(s1);
            }
        }
        m_response.setContentLength(abyte0.length);
        if(s2 == null)
        {
            m_response.setHeader("Content-Disposition","attachment;");
        }
        else
        {
            if(s2.length() == 0)
            {
                m_response.setHeader("Content-Disposition","attachment;");
            }
            else
            {
                m_response.setHeader("Content-Disposition","attachment; filename=" + s2);
            }
        }
        m_response.getOutputStream().write(abyte0,0,abyte0.length);
    }

    public void fieldToFile(ResultSet resultset,String s,String s1) throws ServletException,IOException,SmartUploadException,SQLException
    {
        try
        {
            if(m_application.getRealPath(s1) != null)
            {
                s1 = m_application.getRealPath(s1);
            }
            InputStream inputstream = resultset.getBinaryStream(s);
            FileOutputStream fileoutputstream = new FileOutputStream(s1);
            int i;
            while((i = inputstream.read()) != -1)
            {
                fileoutputstream.write(i);
            }
            fileoutputstream.close();
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		
		String mark = request.getParameter("mark");
		String id = request.getParameter("id");
		String xuesheng = request.getParameter("xuesheng");
		String kemu = request.getParameter("kemu");
		String shijian = request.getParameter("shijian");
		String fenshu = request.getParameter("fenshu");
		
		String str = "";
		String sql = "";
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		
		if(mark != null && mark.equals("add")){
			str = "/jiaoshi/chengji_list.jsp";
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		response.setContentType("text/html;charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		
		String mark = request.getParameter("mark");
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		String jiaoshi = request.getParameter("jiaoshi");
		String keshi = request.getParameter("keshi");
		String beizhu = request.getParameter("beizhu");
		
		String str = "";
		String sql = "";
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		
		if(mark != null && mark.equals("add")){
			str = "/admin/kecheng_list.jsp";
			sql = "insert into kecheng(name,jiaoshi,keshi,beizhu) values('"+name+"','"+jiaoshi+"','"+keshi+"','"+beizhu+"')";
			int flag = ib.insertANDupdateANDdel(sql);
			if(flag == -1){
				str = "/admin/kecheng.jsp?mark="+mark;
				request.setAttribute("message", "课程名称重复!");
			}else{
				request.setAttribute("message", "操作成功!");
			}
		}
		if(mark != null && mark.equals("update")){
			str = "/admin/kecheng_list.jsp";
			sql = "update kecheng set name='"+name+"',jiaoshi='"+jiaoshi+"',keshi='"+keshi+"',beizhu='"+beizhu+"' where id="+id;
			int flag = ib.insertANDupdateANDdel(sql);
			if(flag == -1){
				str = "/admin/kecheng.jsp?mark="+mark+"&id="+id;
				request.setAttribute("message", "课程名称重复!");
			}else{
				request.setAttribute("message", "操作成功!");
			}
		}
		
		RequestDispatcher rd=request.getRequestDispatcher(str);
        rd.forward(request,response);
	}
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		response.setContentType("text/html;charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		
		String mark = request.getParameter("mark");
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		String pwd = request.getParameter("pwd");
		String jiaoshihao = request.getParameter("jiaoshihao");
		String zhenname = request.getParameter("zhenname");
		String sex = request.getParameter("sex");
		String shengri = request.getParameter("shengri");
		String yuanxiao = request.getParameter("yuanxiao");
		String zhuanye = request.getParameter("zhuanye");
		String phone = request.getParameter("phone");
		String address = request.getParameter("address");
		String email = request.getParameter("email");
		
		String str = "";
		String sql = "";
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		
		if(mark != null && mark.equals("add")){
			str = "/admin/jiaoshi_list.jsp";
			sql = "insert into jiaoshi(name,pwd,jiaoshihao,zhenname,sex,shengri,yuanxiao,zhuanye,phone,address,email,shenfen) values('"+name+"','"+pwd+"','"+jiaoshihao+"','"+zhenname+"','"+sex+"','"+shengri+"','"+yuanxiao+"','"+zhuanye+"','"+phone+"','"+address+"','"+email+"','laoshi')";
			int flag = ib.insertANDupdateANDdel(sql);
			if(flag == -1){
				str = "/admin/jiaoshi.jsp?mark="+mark;
				request.setAttribute("message", "用户名或教师号重复!");
			}else{
				request.setAttribute("message", "操作成功!");
			}
		}
		if(mark != null && mark.equals("update")){
			str = "/admin/jiaoshi_list.jsp";
			sql = "update jiaoshi set jiaoshihao='"+jiaoshihao+"',zhenname='"+zhenname+"',sex='"+sex+"',shengri='"+shengri+"',yuanxiao='"+yuanxiao+"',zhuanye='"+zhuanye+"',phone='"+phone+"',address='"+address+"',email='"+email+"' where id="+id;
			int flag = ib.insertANDupdateANDdel(sql);
			if(flag == -1){
			ib.insertANDupdateANDdel(sql);
			request.setAttribute("message", "操作成功!");
		}
		
		if(tuike != null && !tuike.equals("")){
			str = "/xuesheng/kecheng_list.jsp";
			sql = "delete from xuanke where id="+tuike;
			ib.insertANDupdateANDdel(sql);
			request.setAttribute("message", "操作成功!");
		}
		
		RequestDispatcher rd = request.getRequestDispatcher(str);
        rd.forward(request,response);
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
package servlet;

public class XueshengServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public XueshengServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here

请添加图片描述

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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值