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

📄 teacherself.java

📁 这是学生管理网站的java源码,可以管理学生信息
💻 JAVA
字号:
package org.myservlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.myJavabeans.DataConnection;

public class teacherself extends HttpServlet {

	/**
	 * 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 {
		DataConnection d = new DataConnection();
		request.setCharacterEncoding("UTF-8");
		String t_sex = null;
		String t_school = null;
		HttpSession session=request.getSession();
		String t_id=(String)session.getAttribute("id");
		String t_name = request.getParameter("t_name");
		String t_password1 = request.getParameter("t_password1");
		String t_password2 = request.getParameter("t_password2");
		String sex = request.getParameter("t_sex");
		String t_class = request.getParameter("t_class");
		int school = Integer.parseInt(request.getParameter("t_school"));
		String t_phone = request.getParameter("t_phone");
		String t_text = request.getParameter("t_text");
		String t_address = request.getParameter("t_address");
		if (sex.equals("man")) {
			t_sex = "男";
		} else {
			t_sex = "女";
		}
		switch (school) {
		case 1:
			t_school = "大专";
			break;
		case 2:
			t_school = "本科";
			break;
		case 3:
			t_school = "硕士";
			break;
		case 4:
			t_school = "博士";
			break;
		}
		if (t_password1.equals(t_password2)) {
			boolean b = d.UpdateTeacher(t_name, t_id, t_password1, t_sex, t_school, t_class, t_phone, t_address, t_text);
			if (b == true) {
				request.setAttribute("message", "修改成功");
				request.getRequestDispatcher("/admin.jsp").forward(request,
						response);
			}
		} else {
			request.setAttribute("jsp", "teacherselfUpdate.jsp");
			request.setAttribute("message", "两次输入的密码不一致!");
			request.getRequestDispatcher("/error.jsp").forward(request,
					response);
		}
		
	}

}

⌨️ 快捷键说明

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